Prestashop manual order creation problem


  • Default avatar
    warren2    
     11 years ago
    0

    I'm manually creating an order in the backend of Prestashop (1.5.4.1) but when I type in a valid coupon, it is telling me that it is not found.

    Is there any reason that there should be a difference between voucher handling in the front end checkout and in the backend manual order entry?

    Sceenshot: https://dl.dropboxusercontent.com/u/1018200/Screenshots/w.png

    Warren
  • Your avatar
    seyi    
     11 years ago
    0

    Hello,

    To get this to work, you will need to make 2 updates. One of them is a CORE update. The reason is overriding does not seem to work on ajax functions. So the first update is to update the override class:
    in www/override/classes/CartRule.php, at the very end before the last tag:
    <?php
    }
    ?>


    Add this
    <?php
        
    public static function getCartsRuleByCode($name$id_lang) {
        
            
    $sql 'SELECT id*-1 AS id_cart_rule, coupon_code AS name, "" AS description
                      FROM '
    ._DB_PREFIX_.'awocoupon
                      WHERE coupon_code LIKE \'%'
    .pSQL($name).'%\'';
            
    $code Db::getInstance()->executeS($sql);
            if(!empty(
    $code)) return $code;
            
            require_once 
    _PS_MODULE_DIR_.'awocoupon/lib/awoparams.php';
            
    $params = new awoParams();
            if(
    $params->get('enable_store_coupon'1) != 1) return null;

            return 
    parent::getCartsRuleByCode($name$id_lang);
        }
    ?>


    And for the core hack:
    in www/controllers/admin/AdminCartsController.php, around line 516 is this
    <?php
                    
    if (!$this->context->cart->addCartRule((int)$cart_rule->id))
    ?>


    Comment it out and add a new like, like this
    <?php
                    
    //if (!$this->context->cart->addCartRule((int)$cart_rule->id))
                    
    if (!$this->context->cart->addCartRule($cart_rule->id))
    ?>


    That is it, should work after the changes.