VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: urzh12 on June 16, 2016, 03:01:33 AM

Title: CheckOut Button after adding product to cart
Post by: urzh12 on June 16, 2016, 03:01:33 AM
I want to add the "checkout button" once after I add a product to my cart.

Behavior: Click on Menu item to linked product -> Add to cart -> Popup shows options "continue shopping" and "show cart". I want to add a 3rd button for "checkout now".

The show cart is misleading as to just check whats in your cart, even though there is a checkout option presented when you click show cart. I want users to be able to checkout immediately upon adding an item to a cart.

Title: Re: CheckOut Button after adding product to cart
Post by: jenkinhill on June 16, 2016, 10:51:57 AM
Make an override for components/com_virtuemart/views/cart/tmpl/padded.php with a link to the page you want to use for checkout.
Title: Re: CheckOut Button after adding product to cart
Post by: urzh12 on June 21, 2016, 02:07:53 AM
Thank you for the reply.

Screenshot is attached - I want to add a 3rd button for checkout. Can you tell me the override please? Also attached my padded file
Title: Re: CheckOut Button after adding product to cart
Post by: MagikCommerce on June 23, 2016, 07:09:58 AM
Hello urzh12,

You need to create html for checkout button with form in your expected file (e.g. /templates/selected_template/html/com_virtuemart/cart/padded.php) as given follow.

<?php
if (!class_exists('VirtueMartCart')) require(VMPATH_SITE DS 'helpers' DS 'cart.php');
$cart VirtueMartCart::getCart();

if (
$cart->getDataValidated()) {
if($cart->_inConfirm){

$text vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM');
$checkout_task 'cancel';
} else {

$text vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
$checkout_task 'confirm';
}
} else {

$text vmText::_('COM_VIRTUEMART_CHECKOUT_TITLE');
$checkout_task 'checkout';
}

$dynUpdate '';
if( VmConfig::get('oncheckout_ajax',false)) {
$dynUpdate=' data-dynamic-update="1" ';
}
$taskRoute '';
?>


<form method="post" id="checkoutForm" name="checkoutForm" action="<?php echo JRoute::('index.php?option=com_virtuemart&view=cart' $taskRoute$this->useXHTML$this->useSSL); ?>">
            <?php
              echo '<br /><button type="submit" id="checkoutFormSubmit" name="'.$checkout_task.'" value="1" class="vm-button-correct" '.$dynUpdate.'><span>' . $text . '</span> </button>';
           ?>

<input type='hidden' name='order_language' value='<?php echo $this->order_language?>'/>
<input type='hidden' name='task' value='updatecart'/>
<input type='hidden' name='option' value='com_virtuemart'/>
<input type='hidden' name='view' value='cart'/>
</form>



Enjoy Virtuemart !  EnJoy MagikCommerce!

Regards,
MagikCommerce
Title: Re: CheckOut Button after adding product to cart
Post by: urzh12 on June 24, 2016, 04:23:03 AM
Hello!

This worked GREAT! I added <center> attribute so button aligned. See attached. Thanks so much!