Coupon for product "no promo"


  • Default avatar
    guglielmo    
     12 years ago
    0

    hello,
    I wanted to ask if it was possible to create a coupon that did not apply to promotional products?
    You could change the option that allows you to exclude already discounted products?
    thank you
  • Your avatar
    seyi    
     12 years ago
    0

    Not sure if I understand. If you check the 'exclude products on special' checkbox then all products that have a discount associated with them are excluded from the coupon. Is that what you are after?
  • Default avatar
    guglielmo    
     12 years ago
    0

    hello,
    I would like to use your flag into space options to exclude non-discounted products, but those that are on promotion (with the active flag on the state tab virtuemart product)
  • Your avatar
    seyi    
     12 years ago
    0

    I see now. You would need to modify the code for this.
    In www/administrator/components/com_awocoupon/assets/virtuemart/ps_coupon_process.php around line 132 is this
    <?php
        $discount 
    $ps_product->get_discount($session_cart[$i]['product_id']);
    ?>

    Right after that line add this:
    <?php
        
    if($ps_product->get_field($session_cart[$i]['product_id'],'product_special')=='Y'$discount = array('amount'=>0.01);
    ?>


    It should do what you want.
  • Default avatar
    guglielmo    
     12 years ago
    0

    I thank you, but the code is correct as well?

    because it still does not calculate the discount on all products and discounted that I would not calculated on feature product (promo)

    for($i = 0; $i < $session_cart['idx']; $i++) {
    $discount = $ps_product->get_discount($session_cart[$i]['product_id']);
    if($ps_product->get_field($session_cart[$i]['product_id'],'product_special')=='Y') $discount = array('amount'=>0.01);
    $price = $ps_product->get_adjusted_attribute_price($session_cart[$i]['product_id'], $session_cart[$i]['description']);

  • Your avatar
    seyi    
     12 years ago
    0

    The code excludes products from being discounted where the product_special field in jos_vm_products is marked as 'Y'. I tested it locally and it works for me.
  • Default avatar
    guglielmo    
     12 years ago
    0

    but the flag on "Exclude Products on Special" in on or off?

    if off, the coupon work on all product
    if on, work with product whitout discont

    thanks for the patience that you have
  • Your avatar
    seyi    
     12 years ago
    0

    yes, that is how it works. If not checked it will work on all products, if checked it will not work on products that have discounts and products that are marked as special.
  • Default avatar
    guglielmo    
     12 years ago
    0

    ok, but I would not get it to work only on products that are marked as special.

    sample:

    product A € 10
    product B € 20 with 5% discount = € 19
    product C €15 with 15% and marked Special = € 12.75

    Total € 31.75

    Coupon XX = 20% (only product "no special")

    31.75 with coupon XX = 31.75 - 5.8 (20% of 10+19) = 25.95
  • Your avatar
    seyi    
     12 years ago
    0

    oh i see, you want it to work on all products, even discounted, as long as it is not marked as "special". Ok, from the original code I gave you, change
    <?php
        $discount 
    $ps_product->get_discount($session_cart[$i]['product_id']);
    ?>


    to
    <?php
        $discount 
    0;
    ?>


    That should give the desired effect.
  • Default avatar
    guglielmo    
     12 years ago
    0

    I tried your changes but (both flags on or off), the discount applies on all products (discounts and feature).
    My idea would be to allow the flag to exclude only the feauter products, so that the coupon was applied to all other products (with or without discount).
    Maybe I explained I was wrong before.
    thanks
  • Your avatar
    seyi    
     12 years ago
    0

    that is correct and the code should work. For the products that are featured, can you check the database and look at table jos_vm_product and the product_special column. Do all your featured products have the letter 'Y' in that column?
  • Default avatar
    guglielmo    
     12 years ago
    0

    my featured products have letter Y in the special column.
    can you repet the exact script?
    p.s. my awocoupon version is 1.4.1
    many thanks
  • Your avatar
    seyi    
     12 years ago
    0

    Here it is again, the full version:

    In www/administrator/components/com_awocoupon/assets/virtuemart/ps_coupon_process.php around line 132 is this

    <?php
        $discount 
    $ps_product->get_discount($session_cart[$i]['product_id']);
    ?>

    Change it to this:

    <?php
        $discount 
    0;
        if(
    $ps_product->get_field($session_cart[$i]['product_id'],'product_special')=='Y'$discount = array('amount'=>0.01);
    ?>



    Seyi