Coupon code exceeds amount, won't allow payment method or shipping method:


  • Default avatar
    emily6    
     12 years ago
    0

    So I've scoured the forums here and none of the fixes or problems seem to be exactly what I'm dealing with.

    I think my virtuemart needs the $ amount in cart to be greater than 0 in order to allow 'select payment method' to appear, but I don't know why it won't allow 'select shipping method' as well.

    I ran into this problem before using AWOpro, and I had solved it by adding a bit in my ps_coupon.php file that if the code is greater than total, the code would equal the total plus one cent.:

    https://forum.virtuemart.net/index.php?topic=82683.msg289879#msg289879

    Is my post about it. It worked great! Since we do a lot of promotions with daily deal type sites, this scenario is fairly common for us.

    But after installing awo and then upgrading to awopro I can see that code is still there in my ps_coupon.php file but now it doesn't work. I'm back to square one.

    If i input a code for $20 on a total of $14.95 the message displays 'code temporarily set to $14.95'. Before it would have said 'code is temporarily set to $14.94', which allowed us to send payment to paypal, etc.

    If this is indeed the basic problem, I would like to figure out how to make it add that extra cent in for my work-around solution. I think that might do the trick.

    Thanks in advance for your reply,

    Forrestt

    http://www.FromWarToPeace.com
  • Your avatar
    seyi    
     12 years ago
    0

    Hello Forrestt

    You can add the same trick to AwoCoupon,

    in www/administrator/components/com_awocoupon/assets/virtuemart/ps_coupon_process.php, search for this line
    <?php
            
    if( $total $coupon_value ) {
    ?>


    I think it is in 3 places. Within the loop you can subtract the penny.
  • Default avatar
    emily6    
     12 years ago
    0

    That worked like a charm. Shipping method shows up, payment method shows up and now it will succesfully send transaction to paypal.

    You rock.
  • Default avatar
    michiel    
     11 years ago
    0

    And how to do this in AwoCoupon 2.x?
  • Default avatar
    fromwartopeace    
     11 years ago
    0

    Hey Seyi,

    I thought i posted this a little bit ago, but it appears to not be here so I'll try again.

    I'm trying to do the same thing that forrestt did. I am actually running the same site that he was running and we are getting the same error that he did. When i access the file that you recommend to him there is no:

    <?php
            
    if( $total $coupon_value ) {
    ?>


    I'm quite confused with how to proceed, and I am getting lots of complaints about people not being able to choose a shipping method for some reason. Any help would be greatly appreciated!

    Thanks,

    Patrick
  • Your avatar
    seyi    
     11 years ago
    0

    In AwoCoupon 1, the file has moved to
    www/administrator/components/com_awocoupon/helpers/vm_coupon.php

    You should find it in there.
  • Your avatar
    seyi    
     11 years ago
    0

    Can I ask why you would want to do this in 2.x? Is it because Virtuemart does not handle 0 order total very well with payment methods? If so there is a better solution.
  • Default avatar
    michiel    
     11 years ago
    0

    Yes that is my problem; my payment module for internet banking is giving an error for 0 euro payments. If you have a better solution then I like to know.

    Thanks

    Michiel
  • Your avatar
    seyi    
     11 years ago
    0

    Hello,

    I submitted a patch to Virtuemart to get this fixed and should show up in the next version. If you would like it now, here it is, this is Virtuemart 2.0.14:




    in www/components/com_virtuemart/helpers/cart.php,
    around line 943 is this function
    <?php
        
    private function confirmedOrder() {

            
    //Just to prevent direct call
            
    if ($this->_dataValidated && $this->_confirmDone) {

                
    $orderModel VmModel::getModel('orders');

                if ((
    $orderID $orderModel->createOrderFromCart($this)) === false) {
                    
    $mainframe JFactory::getApplication();
                    
    JError::raiseWarning(500'No order created '.$orderModel->getError());
                    
    $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart') );
                }
                
    $this->virtuemart_order_id $orderID;
                
    $order$orderModel->getOrder($orderID);

                
    $dispatcher JDispatcher::getInstance();

                
    JPluginHelper::importPlugin('vmshipment');
                
    JPluginHelper::importPlugin('vmcustom');
                
    JPluginHelper::importPlugin('vmpayment');
                
    $returnValues $dispatcher->trigger('plgVmConfirmedOrder', array($this$order));
                
    // may be redirect is done by the payment plugin (eg: paypal)
                // if payment plugin echos a form, false = nothing happen, true= echo form ,
                // 1 = cart should be emptied, 0 cart should not be emptied

            
    }


        }
    ?>


    change it to this
    <?php
        
    private function confirmedOrder() {

            
    //Just to prevent direct call
            
    if ($this->_dataValidated && $this->_confirmDone) {
                {  
    # seyi_code zero order total
                    
    $prices $this->getCartPrices();
                    if(
    $prices['billTotal']<=0$this->virtuemart_paymentmethod_id 0;
                }

                
    $orderModel VmModel::getModel('orders');

                if ((
    $orderID $orderModel->createOrderFromCart($this)) === false) {
                    
    $mainframe JFactory::getApplication();
                    
    JError::raiseWarning(500'No order created '.$orderModel->getError());
                    
    $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart') );
                }
                
    $this->virtuemart_order_id $orderID;
                
    $order$orderModel->getOrder($orderID);

                
    $dispatcher JDispatcher::getInstance();

                
    JPluginHelper::importPlugin('vmshipment');
                
    JPluginHelper::importPlugin('vmcustom');
                
    JPluginHelper::importPlugin('vmpayment');
                
    $returnValues $dispatcher->trigger('plgVmConfirmedOrder', array($this$order));
                
    // may be redirect is done by the payment plugin (eg: paypal)
                // if payment plugin echos a form, false = nothing happen, true= echo form ,
                // 1 = cart should be emptied, 0 cart should not be emptied

                
    if($prices['billTotal']<=0) {  # seyi_code zero order total
                    
    $modelOrder VmModel::getModel('orders');
                    
    $order['order_status'] = 'C';
                    
    $order['customer_notified'] = 1;
                    
    $order['comments'] = '';
                    
    $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id$ordertrue);
                    
    //$order['paymentName']= $dbValues['payment_name'];
                    //We delete the old stuff
                    
    $this->emptyCart();
                }
            }


        }
    ?>





    around line 844 is this code


    <?php
            
    //Test Payment and show payment plugin
            
    if (empty($this->virtuemart_paymentmethod_id)) {
                return 
    $this->redirecter('index.php?option=com_virtuemart&view=cart&task=editpayment' $redirectMsg);
            } else {
                if(!
    class_exists('vmPSPlugin')) require(JPATH_VM_PLUGINS.DS.'vmpsplugin.php');
                
    JPluginHelper::importPlugin('vmpayment');
                
    //Add a hook here for other payment methods, checking the data of the choosed plugin
                
    $dispatcher JDispatcher::getInstance();
                
    $retValues $dispatcher->trigger('plgVmOnCheckoutCheckDataPayment', array( $this));

                foreach (
    $retValues as $retVal) {
                    if (
    $retVal === true) {
                        break; 
    // Plugin completed succesful; nothing else to do
                    
    } elseif ($retVal === false) {
                        
    // Missing data, ask for it (again)
                        
    return $this->redirecter('index.php?option=com_virtuemart&view=cart&task=editpayment' $redirectMsg);
                        
    //     NOTE: inactive plugins will always return null, so that value cannot be used for anything else!
                    
    }
                }
            }
    ?>


    change it to this
    <?php
            $prices 
    $this->getCartPrices(); # seyi_code zero order total
            
    if($prices['billTotal']>0) {
                
    //Test Payment and show payment plugin
                
    if (empty($this->virtuemart_paymentmethod_id)) {
                    return 
    $this->redirecter('index.php?option=com_virtuemart&view=cart&task=editpayment' $redirectMsg);
                } else {
                    if(!
    class_exists('vmPSPlugin')) require(JPATH_VM_PLUGINS.DS.'vmpsplugin.php');
                    
    JPluginHelper::importPlugin('vmpayment');
                    
    //Add a hook here for other payment methods, checking the data of the choosed plugin
                    
    $dispatcher JDispatcher::getInstance();
                    
    $retValues $dispatcher->trigger('plgVmOnCheckoutCheckDataPayment', array( $this));

                    foreach (
    $retValues as $retVal) {
                        if (
    $retVal === true) {
                            break; 
    // Plugin completed succesful; nothing else to do
                        
    } elseif ($retVal === false) {
                            
    // Missing data, ask for it (again)
                            
    return $this->redirecter('index.php?option=com_virtuemart&view=cart&task=editpayment' $redirectMsg);
                            
    //     NOTE: inactive plugins will always return null, so that value cannot be used for anything else!
                        
    }
                    }
                }
            }
    ?>



    Then in your template, the default his here
    www/components/com_virtuemart/views/cart/tmpl/default_pricelist.php
    but you may have it overriden, in which case it will be here
    www/templates/[your_template_name]/html/com_virtuemart/cart/tmpl/default_pricelist.php
    around line 338 is this

    <tr class="sectiontableentry1">
        <?php if (!$this->cart->automaticSelectedPayment) { ?>

        <td colspan="4" align="left">
            <?php echo $this->cart->cartData['paymentName']; ?>
            <br/>
            <?php if (!empty($this->layoutName) && $this->layoutName == 'default') {
            echo 
    JHTML::('link'JRoute::('index.php?view=cart&task=editpayment'$this->useXHTML$this->useSSL), $this->select_payment_text'class=""');
        } else {
            
    JText::('COM_VIRTUEMART_CART_PAYMENT');
        } 
    ?> </td>

        </td>
        <?php } else { ?>
        <td colspan="4" align="left"><?php echo $this->cart->cartData['paymentName']; ?> </td>
        <?php ?>
        <?php if (VmConfig::get ('show_tax')) { ?>
        <td align="right"><?php echo "<span  class='priceColor2'>" $this->currencyDisplay->createPriceDiv ('paymentTax'''$this->cart->pricesUnformatted['paymentTax'], FALSE) . "</span>"?> </td>
        <?php ?>
        <td align="right"><?php // Why is this commented? what is with payment discounts? echo "<span  class='priceColor2'>".$this->cart->pricesUnformatted['paymentDiscount']."</span>"; ?></td>
        <td align="right"><?php  echo $this->currencyDisplay->createPriceDiv ('salesPricePayment'''$this->cart->pricesUnformatted['salesPricePayment'], FALSE); ?> </td>
    </tr>


    change it to this
    <tr class="sectiontableentry1">
        <?php if ($this->cart->pricesUnformatted['billTotal']>0) { # seyi_code zero order total ?>
            <?php if (!$this->cart->automaticSelectedPayment) { ?>

            <td colspan="4" align="left">
                <?php echo $this->cart->cartData['paymentName']; ?>
                <br/>
                <?php if (!empty($this->layoutName) && $this->layoutName == 'default') {
                echo 
    JHTML::('link'JRoute::('index.php?view=cart&task=editpayment'$this->useXHTML$this->useSSL), $this->select_payment_text'class=""');
            } else {
                
    JText::('COM_VIRTUEMART_CART_PAYMENT');
            } 
    ?> </td>

            </td>
            <?php } else { ?>
            <td colspan="4" align="left"><?php echo $this->cart->cartData['paymentName']; ?> </td>
            <?php ?>
            <?php if (VmConfig::get ('show_tax')) { ?>
            <td align="right"><?php echo "<span  class='priceColor2'>" $this->currencyDisplay->createPriceDiv ('paymentTax'''$this->cart->pricesUnformatted['paymentTax'], FALSE) . "</span>"?> </td>
            <?php ?>
            <td align="right"><?php // Why is this commented? what is with payment discounts? echo "<span  class='priceColor2'>".$this->cart->pricesUnformatted['paymentDiscount']."</span>"; ?></td>
            <td align="right"><?php  echo $this->currencyDisplay->createPriceDiv ('salesPricePayment'''$this->cart->pricesUnformatted['salesPricePayment'], FALSE); ?> </td>
        <?php ?>
    </tr>


    Thats it

    There is also a paypal solution if you prefer:
    https://awodev.com/forum/awocoupon/help-section/error-coupon-equal-sales-price#comment-2981
  • Default avatar
    peter49    
     11 years ago
    0

    Hi Seyi, I followed this hack exactly and it does work (great!), but only when I have 'Enable Automatic Selected Payment?' UNchecked in the back-end of Virtuemart. This means an extra step for my customers, I have only 1 payment method (Multisafepay).

    Now, is there a way to have automatic payment enabled and still have the hack working? Thanks for helping out!

    Peter
  • Default avatar
    peter49    
     11 years ago
    0

    Solved it. It turns out the hack IS working with automatic payment enabled, but Multisafepay returns an error message anyway because the amount to pay is 0.

    I have replaced the error message in multisafepay.php with $html = '

    '.JText::_('VMPAYMENT_SAINT_STATUS_COMPLETED').'

    '; (line 191).

    Now the hack works and I get the proper confirmation text.

  • Default avatar
    Cotec    
     10 years ago
    0

    TO get the Coupon's and Paypal to work for free orders I had to use a custom script. Basiclly if I do not then virtuemart will always put it in "pending" With the script it will make the order "completed"

    So here is the original:

    in www/components/com_virtuemart/helpers/cart.php,
    around line 943 is this function

    <?php
        
    private function confirmedOrder() {
           

    //Just to prevent direct call
            
    if ($this->_dataValidated && $this->_confirmDone) {
               

    $orderModel VmModel::getModel('orders');
                if ((

    $orderID $orderModel->createOrderFromCart($this)) === false) {
                    
    $mainframe JFactory::getApplication();
                    
    JError::raiseWarning(500'No order created '.$orderModel->getError());
                    
    $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart') );
                }
                
    $this->virtuemart_order_id $orderID;
                
    $order$orderModel->getOrder($orderID);
               

    $dispatcher JDispatcher::getInstance();
               

    JPluginHelper::importPlugin('vmshipment');
                
    JPluginHelper::importPlugin('vmcustom');
                
    JPluginHelper::importPlugin('vmpayment');
                
    $returnValues $dispatcher->trigger('plgVmConfirmedOrder', array($this$order));
                
    // may be redirect is done by the payment plugin (eg: paypal)
                // if payment plugin echos a form, false = nothing happen, true= echo form ,
                // 1 = cart should be emptied, 0 cart should not be emptied
           

    }
        }

    ?>


    Here is the custom:

    <?php
        
    private function confirmedOrder() {
           

    //Just to prevent direct call
            
    if ($this->_dataValidated && $this->_confirmDone) {
               

    $orderModel VmModel::getModel('orders');
                if ((

    $orderID $orderModel->createOrderFromCart($this)) === false) {
                    
    $mainframe JFactory::getApplication();
                    
    JError::raiseWarning(500'No order created '.$orderModel->getError());
                    
    $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart') );
                }
                
    $this->virtuemart_order_id $orderID;
                
    $order$orderModel->getOrder($orderID);
               

    $dispatcher JDispatcher::getInstance();
               

    JPluginHelper::importPlugin('vmshipment');
                
    JPluginHelper::importPlugin('vmcustom');
                
    JPluginHelper::importPlugin('vmpayment');
                
    $returnValues $dispatcher->trigger('plgVmConfirmedOrder', array($this$order));
                
    // may be redirect is done by the payment plugin (eg: paypal)
                // if payment plugin echos a form, false = nothing happen, true= echo form ,
                // 1 = cart should be emptied, 0 cart should not be emptied
           

    }
        }

    ?>


    Problem is with the script on it will then trigger a problem with Download for sale. It will say "TCPDF ERROR: [Image] Unable to get image: http://www.subaqueousmusic.com/plugins/vmcustom/downloads_for_sale/downloads_for_sale/assets/download_medium.png"

    Not sure why it says that. I checked and that file is exactly where it needs to be.

    What is happening here?
  • Your avatar
    seyi    
     10 years ago
    0

    Hello,

    Not sure, maybe the file does not exist or it does not like the file extension. Have you checked the path?

    There may be a solution in Virtuemart forum also, for example:
    https://forum.virtuemart.net/index.php?topic=108140.0