Buy X get Y - different products.


  • Your avatar
    stefan_mario    
     5 years ago
    0

    Hey Seyi!

    Got buy 2 on catgorie X (VM) and get 1 from categorie Y - "Automatically add to cart 'Get Y' product". So far so good. 
    I want to allow the customer to use it as often as they want.


    The problem when the customer enters the coupon he always gets more of the same product instead of a mix from the category. When they buy 10 products from X they get the same 5 products from Y eventhough I declared the whole category. That's bullocks. I'd like to have those Get Y mixed. How do I do that? 

    Thanks a lot.

  • Your avatar
    seyi    
     5 years ago
    0

    Try making this change and see if it works well.  In the file:

    www/administrator/components/com_awocoupon/helper/estore/virtuemart/class-awocoupon-helper-estore-virtuemart-discount.php, around line 1481 is this:

    <?php
                            $sql 
    'SELECT c.virtuemart_product_id
                                      FROM #__virtuemart_product_categories c
                                      JOIN #__virtuemart_products p ON p.virtuemart_product_id=c.virtuemart_product_id
                                     WHERE p.published=1
                                       AND c.virtuemart_category_id IN (' 
    $ids ')
                                       AND c.virtuemart_product_id NOT IN (' 
    implode','$used_ids ) . ')
                                       ' 
    $where_product '
                                       LIMIT 1
                            '
    ;
    ?>

    Change it to this:
    <?php
                            $sql 
    'SELECT c.virtuemart_product_id
                                      FROM #__virtuemart_product_categories c
                                      JOIN #__virtuemart_products p ON p.virtuemart_product_id=c.virtuemart_product_id
                                     WHERE p.published=1
                                       AND c.virtuemart_category_id IN (' 
    $ids ')
                                       AND c.virtuemart_product_id NOT IN (' 
    implode','$used_ids ) . ')
                                       ' 
    $where_product '
                                     ORDER BY RAND()
                                       LIMIT 1
                            '
    ;
    ?>

  • Your avatar
    stefan_mario    
     5 years ago
    0

    Nope, sorry didn't work. :(
  • Your avatar
    seyi    
     5 years ago
    0

    It should.  The code is specific for your get y being category/include.  Is that what it is setup as?