10% off on just one item in the cart


  • Default avatar
    dirk    
     12 years ago
    0

    Hi there,

    I have some coupons out there that provide "10% off your next item" for a one-time usage. I have 4 different products and it is ok that the 10% go off the most expensive item in the cart, but only to one of the items, not all of them.

    Can this be configured somehow? THANKS!!
    Dirk
  • Your avatar
    seyi    
     12 years ago
    0

    you can setup a quantity stop coupon, by using the value definition. In user_guide.html, take a look a the value definition section.
  • Default avatar
    dirk    
     12 years ago
    0

    Perfect - that works. It seems it uses it oly on the first type of items in the cart. Is there a way to configure it to use it on the most expensive one?
    Dirk
  • Your avatar
    seyi    
     12 years ago
    0

    there is no option for that. would need to customize AwoCoupon.
  • Your avatar
    seyi    
     12 years ago
    0

    Hey Dirk, here is a solution. If implemented then any quantity stop coupon will always work this way:

    Version 1.4.1
    in www/administrator/components/com_awocoupon/assets/ps_coupon_process.php around line 874, after this
    <?php
    $qty 
    $qty_distinct $total 0;
    ?>


    add this
    <?php
    if(!empty($max_qty)) {
        
    $coupon_row->cart_items sortmulti($coupon_row->cart_items,'product_price','desc');
    }
    ?>


    Then around line 16, after
    <?php
    if(!function_exists('printrx')) { function printrx($a) { echo '<pre>'.print_r($a,1).'</pre>'; exit; } }
    ?>


    add this
    <?php
    function sortmulti ($array$index$order$natsort=FALSE$case_sensitive=FALSE) {
            if(
    is_array($array) && count($array)>0) {
                foreach(
    array_keys($array) as $key
                
    $temp[$key]=$array[$key][$index];
                if(!
    $natsort) {
                    if (
    $order=='asc')
                        
    asort($temp);
                    else    
                        
    arsort($temp);
                }
                else 
                {
                    if (
    $case_sensitive===true)
                        
    natsort($temp);
                    else
                        
    natcasesort($temp);
                if(
    $order!='asc'
                    
    $temp=array_reverse($temp,TRUE);
                }
                foreach(
    array_keys($temp) as $key
                    if (
    is_numeric($key))
                        
    $sorted[]=$array[$key];
                    else    
                        
    $sorted[$key]=$array[$key];
                return 
    $sorted;
            }
        return 
    $sorted;
    }
    ?>


    This will sort the items in the cart based on price and the most expensive will be processed first
  • Default avatar
    michael85    
     12 years ago
    0

    Hi Seyi,

    first of all: great job. Saved me a lot of time configuring VM on Dirks website.

    Unfortunately your workaround causes a little problem.
    The items are sorted and the coupon is triggered for the most expensive item. So far so good. :-)
    But as we also have a gift certificate product on which the customer can insert an amount and that's the price then.
    We wanted to exclude this customer-gift-certificate from awo-coupon, but it seems that if the amount of the gift-certificate has the highest value of all items in cart, the coupon is triggered, never the less of what I configure in Backend (excluded Products or Categories are being ignored now)

    Any idea where I could look in the source code to "re-activate" this feature of excluding products?

    Cheers,
    Mike
  • Your avatar
    seyi    
     12 years ago
    0

    Is your discount type set to "specific"? If set to "overall" it looks at everything in the cart. For your custom products, you should be able to exclude the product id from the products list.
  • Default avatar
    michael85    
     12 years ago
    0

    Thanks again. After setting to "specific" it works!!
  • Default avatar
    dirk    
     12 years ago
    0

    Hi Seyi,
    the site is online and I need to create 250 of the same coupons, e.g. with name A-001 to A-250. How can I do that best? Can I set up a series?
    Thanks! Dirk
  • Your avatar
    seyi    
     12 years ago
    0

    awocoupon->import

    Best not to use coupon codes in series, makes it easy for hackers.

    Also please start a new thread when it is unrelated to the original topic.
  • Default avatar
    paul73    
     12 years ago
    0

    Hi,
    Please can you tell me how to edit the files in v1.4.4 Pro to achieve the same sorting of the items in the cart so that I can apply the discount to only the cheapest item? I could not find the code you describe in your original instructions for v1.4.1.
    Thank you
  • Your avatar
    seyi    
     12 years ago
    0

    The code has been moved to administrator/components/com_awocoupon/helpers/vm_coupon.php. The post still applies in the new file.
  • Default avatar
    paul73    
     12 years ago
    0

    Great! Thank you for helping so promptly.