Hey again, Today i got one solution to add reorder button in Viruemart 3 with Joomla 3.x, I have seen many paid plugin and there is not free plugins to do this, Now im going to describe you step by step how to do so if you are developer then you will get idea and even you don’t know ask me i will help you to do this within a 10 minute.
Now let’s go to add virtuemart reorder button in order list as well as in order.
Step 1:
First you need Joomla access credentials , or you can do using FTP or cPanel also, so we login into Joomla website first then go into Extensions> Templets > Templets >Select your Joomla theme/templet
See below
See com_virtuemart > orders folder is exist or not in html if not then you need to override templet for save your work on feature Joomla or Vituemart updates, Now below is simple step to override templet in Joomla
So click on Create override tab and then select com_virtuemart as and then click on orders to Joomla will create copy that templet files into above mention place in html.
Step 2:
First add code into order list templet file (/html/com_virtuemart/orders/list.php)
Now you need to add one more columns in order list is reorder so
<thead>
<tr>
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDER_LIST_ORDER_NUMBER'); ?>
</th>
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDER_LIST_CDATE'); ?>
</th>
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDER_LIST_MDATE'); ?>
</th>
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDER_LIST_STATUS'); ?>
</th>
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDER_LIST_TOTAL'); ?>
</th>
<!-- This th we have added for show button in list -->
<!-- Start our code-->
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDERS_RE_ORDER'); ?>
</th>
<!-- End our code-->
</thead>
Now we are going to add button and that is important part of this article. on same folder if we scroll down and we can see below code
<thead>
<tr>
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDER_LIST_ORDER_NUMBER'); ?>
</th>
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDER_LIST_CDATE'); ?>
</th>
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDER_LIST_MDATE'); ?>
</th>
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDER_LIST_STATUS'); ?>
</th>
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDER_LIST_TOTAL'); ?>
</th>
<!-- This th we have added for show button in list -->
<!-- Start our code-->
<th>
<?php echo vmText::_('COM_VIRTUEMART_ORDERS_RE_ORDER'); ?>
</th>
<!-- End our code-->
</thead>
So one above code we have added one td and inside of that td we added one form and set action into cart page. below is your layout of order list page.
Step 3:
Now we need to add button on order detail page, this is same thing we need to do on file. For order details we need to add above code with some adjustment in html/com_virtuemart/orders/details.php file.
You need to add below code where you want to put reorder button.
<?php
/**
*
* Order detail view
*
* @package VirtueMart
* @subpackage Orders
* @author Oscar van Eijk, Valerie Isaksen
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: details.php 6246 2012-07-09 19:00:20Z Milbo $
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
JHtml::stylesheet('vmpanels.css', JURI::root().'components/com_virtuemart/assets/css/');
if($this->print){
?>
<body onLoad="javascript:print();">
<div><img src="<?php echo JURI::root() . $this-> vendor->images[0]->file_url ?>"></div>
<h2><?php echo $this->vendor->vendor_store_name; ?></h2>
<?php echo $this->vendor->vendor_name .' - '.$this->vendor->vendor_phone ?>
<h1><?php echo JText::_('COM_VIRTUEMART_ACC_ORDER_INFO'); ?></h1>
<div class='spaceStyle'>
<?php
echo $this->loadTemplate('order');
?>
</div>
<div class='spaceStyle'>
<?php
echo $this->loadTemplate('items');
?>
</div>
<?php echo $this->vendor->vendor_letter_footer_html; ?>
</body>
<?php
} else {
?>
<div class="cart-view">
<h3 class="module-title"><?php echo JText::_('COM_VIRTUEMART_ACC_ORDER_INFO'); ?>
<?php
/* Print view URL */
$details_link = "<a href=\"javascript:void window.open('$this->details_url', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no');\" >";
//$details_link .= '<span class="hasTip print_32" title="' . JText::_('COM_VIRTUEMART_PRINT') . '"> </span></a>';
$button = (JVM_VERSION==1) ? '/images/M_images/printButton.png' : 'system/printButton.png';
$details_link .= JHtml::_('image',$button, JText::_('COM_VIRTUEMART_PRINT'), NULL, true);
$details_link .= '</a>';
echo $details_link; ?>
</h3>
<?php if($this->order_list_link){ ?>
<div class='spaceStyle first'>
<div class="back-to-category" >
<a class="button_back button reset2" href="<?php echo $this->order_list_link ?>"><i class="fa fa-reply"></i><?php echo JText::_('COM_VIRTUEMART_CATEGORY_BACK_TO_ORDER').' '.JText::_('COM_VIRTUEMART_ORDERS_VIEW_DEFAULT_TITLE'); ?><span></span></a>
</div>
<div class="clear"></div>
</div>
<?php }?>
<div class='spaceStyle second'>
<?php
echo $this->loadTemplate('order');
?>
</div>
<form method="post" class="reorder" action="<?=JRoute::_("index.php?option=com_virtuemart&view=cart");?>">
<input type="hidden" name="option" value="com_virtuemart">
<input type="hidden" name="view" value="cart">
<input type="hidden" name="task" value="add">
<?php
foreach($this->orderdetails['items'] as $item){
?>
<input type="hidden" class="item_id" name="virtuemart_product_id[]" value="<?=$item->virtuemart_product_id;?>">
<input type="hidden" name="virtuemart_category_id[]" value="<?=$item->virtuemart_category_id;?>">
<input type="hidden" class="quantity-input js-recalculate" name="quantity[]" value="<?=$item->product_quantity;?>" >
<?php
}
?>
<input name="addtocart" type="submit" title="Re order" class="addtocart-button cart-click" value="<?=JText::_('COM_VIRTUEMART_ORDERS_RE_ORDER');?>" style="
float: right;
position: relative;
top: 39px; z-index: 999;
">
</form>
<div class='spaceStylebot shoper'>
<?php
$tabarray = array();
$tabarray['items'] = 'COM_VIRTUEMART_ORDER_ITEM';
$tabarray['history'] = 'COM_VIRTUEMART_ORDER_HISTORY';
shopFunctionsF::buildTabs ( $this, $tabarray); ?>
</div>
<br clear="all"/>
</div>
<?php
}
?>
So on that page you will see the button and when you click all items will added back into cart.
Feel free comment me or ask me if you having any issues.
Xavi says
Hi Parbat,
great tip, thank you very much.
I am trying to do as you say but I can’t see the code in Step 3.
Would you please check?
Thanks
Parbat Pithiya says
We have added step3 data, somehow that was deleted.