Gift Certificate applies to shipping with no qualifying product


  • Default avatar
    opt2bout    
     7 years ago  last edited 7 years ago
    0

    I'm not sure how to work around this.  We have created an AWO coupon gift certificate (Hikashop) and the ordering of the gift certificate, etc. works fine.

    The problem I am having is that I have created a template for a gift certificate that is restricted to specific products.  If you go into the shopping cart and add an item that is NOT allowed, the gift certificate can still be used to apply to the Shipping calculated on the order.

    So this allows a user to use a gift certificate for a specific product to be used on shipping for non-qualifying products.  I know I can exclude shipping, but then we do want someone with a qualifying product to be able to include shipping if possible.

  • Your avatar
    seyi    
     7 years ago
    0

    Hello,

    Unfortunately cannot do what you want to do.  You can setup gift certificate to work with specific product/shipping, but you cant say if it works for product A then also discount shipping, and if it does not work for product B then do not discount shipping.
  • Default avatar
    opt2bout    
     7 years ago
    0

    I guess we just expect the coupon, gift card or a discount code to not apply at all if none of the conditions are met. Otherwise people will be able to use a discount good for Product A on other product's shipping.


    I would also like to request a consideration for an option to not allow for all shipping options.  Right now if we add a new shipping option, we have to edit all of the discounts and gift card purchases to exclude the newly addded shipping.

    Thanks

  • Your avatar
    seyi    
     7 years ago  last edited 7 years ago
    0

    opt2bout @ Dec 1, 2016, 10:09:59 AM

    I would also like to request a consideration for an option to not allow for all shipping options.  Right now if we add a new shipping option, we have to edit all of the discounts and gift card purchases to exclude the newly addded shipping.

    Thanks



    Hello,

    Can you clarify what you mean by this? Are you using the exclude option?  If there is specific shipping that can be used, why not use 'include' then, so no need to edit after adding new shipping?

  • Default avatar
    opt2bout    
     7 years ago  last edited 7 years ago
    0

    Because if we leave it as Include and don't select any shipping option in the list, it will then apply the coupon/discount/gift certificate to any shipping charges.
  • Your avatar
    seyi    
     7 years ago  last edited 7 years ago
    0

    So you basically want to disable shipping discounts for gift certificates?
  • Default avatar
    opt2bout    
     7 years ago
    0

    Yeah.  Again, what is happening is that we issue gift certificates or discounts for specific products and then found that users were using those certificates for shipping other products altogether.  So my thinking here is if I can disable any shipping option the discount can't be used at all unless a qualifying product is added to the cart.
  • Your avatar
    seyi    
     7 years ago
    0

    Hello,

    Ok, so there are 2 ways the gift certificate works:
    1. If you do not select restrictions, then it will work for all products and all shipping
    2. If you select specific products, then it will not work for any shipping unless you select specific shipping methods when creating the gift certificate

  • Default avatar
    opt2bout    
     7 years ago  last edited 7 years ago
    0

    That would be great!  (but just to make sure I read your response correctly, are you telling me that is how it is going to work?  Just to be clear, that isn't the way it works right now.) ???

    Edit: in fact now, I may have screwed everything up...I can't get the categories to work at all...but the coupon works for shipping, even though I don't have any shipping selected.  There could be something else wrong?
  • Your avatar
    seyi    
     7 years ago
    0

    It should already work that way, just tested and see that it does not.  Not show how that changed.  Ok, here is the fix:
    in the file www/administrator/components/com_awocoupon/helpers/estore/estorecouponhandler.php, around line 1040 is this:
    <?php
                $coupon_row
    ->giftcert_shipping $total_shipping;
                $coupon_row->giftcert_shipping_notax $total_shipping_notax;
    ?>


    Right after that, add this:
    <?php
                
    if(empty($asset1list) || (!empty($asset1list) && !empty($asset2list))) ; else $coupon_row->giftcert_shipping $coupon_row->giftcert_shipping_notax 0;
    ?>


    That should fix the issue.  For categories, I have not seen any problems there.  I have been testing and it is working fine for me.

  • Default avatar
    opt2bout    
     7 years ago  last edited 7 years ago
    0

    Great, the shipping is no longer being applied, but now in all of my testing I may have screwed up my gift certificate.  I have it set to include only a single category...but I didn't also select all of the sub-cats below that...so I thought that is what I was doing wrong...but now I have all categories and sub-categories selected in the Include and now my coupon won't apply to the merchandise.

    However, the shipping charges are NO longer being applied...Thank you for that...now I'll need to go back to my template and see if I did something else wrong.  I'm not getting any pop-up message telling me the coupon is invalid or anything either.

    Okay, I got it.  I kept trying different permutations to try and get things to work I just messed things up too much :( 

    Shipping is back on track, thank you!

    But I've got my coupon/gift card back the way it was, and the changes to the helper file take care of all but one issue.  The coupon is still being applied to products that aren't in the include list.  I just noticed it for the shipping during testing, but my tests were using a valid product.

    But now that the shipping issue is addressed, I realized now that a user can add non-qualifying products to the shopping cart and it will apply the discount/credit to any item in the cart if only one qualifying product is there.

    I'm not sure what I'm doing wrong.  I'm wondering if this has to do with variants?  I'm guessing here so forgive me.

    I have a gift card (I'm actually modifying the coupon that was created by the Gift Card process itself)...I change the restrictions by category or by manufacturer and the restrictions don't apply at either level (of course Brand is just a category within Hikashop).

    Anyway the only thing that I've noticed is that internally, inside Hikashop, the "Brand" and the "Category" are set inside each individual variant.

    I've tried rebuilding the category tree in Hikashop, etc.  I'm not sure what else to do.
  • Your avatar
    seyi    
     7 years ago
    0

    Hello,

    Ok, not really sure here.  Are you saying you select a category in a gift certificate and in the front end the coupon does not work in a product with that specific category?
  • Default avatar
    opt2bout    
     7 years ago
    0

    Yes.  I tried clearing cache, deleting cookies, etc. thinking maybe my browser was confused (did you know you can't disable cache in Firefox now???)  I have even tried using Brand (Manufacturer) which is really just a special category in Hikashop.  If I choose the top-most category, or if I use Manufacturer, it won't apply the coupon at all.
  • Your avatar
    seyi    
     7 years ago
    0

    Hello,
    'Top most category', the product has to be in this category.  If the product is not in that category but in a child category of that then you must select the child category. 
  • Default avatar
    opt2bout    
     7 years ago
    0

    Yeah, that's what we figured, which again poses a problem as the store owners make changes and add sub-categories in the future, then all coupons and discount codes would have to be edited...a bit of a mess...however, that is why I chose to change to using Manufacturer...or Brand...but that doesn't work either so the same issue with categories much apply here as well since Brand is really just another category.
  • Your avatar
    seyi    
     7 years ago
    0

    Hello,

    How about creating a special category, unpublished category, which you add to the coupon.  Then you can add all the qualifying products to that category and in the future, you would not need to edit each gift certificate, simply the category.


  • Default avatar
    opt2bout    
     7 years ago
    0

    Is there any way to get the manufacturer criterion to work properly?
  • Your avatar
    seyi    
     7 years ago
    0

    Hello,

    I have tested the manufacturer function and not getting any issues with it:

    - i created a coupon adding one manufacturer and including
    - in hikashop I added the brand entered in the coupon to a specific product
    - in front end, tried using the gift cert and it worked
    - altered the gift certificate to exclude the manufacturer
    - tried the gift certificate in the front end and it did not work


  • Default avatar
    opt2bout    
     7 years ago  last edited 7 years ago
    0

    Doesn't work for me.  But based on how the category selection works my guess is that your test product doesn't have any variants.

    I think it is the same issue with not being able to include sub-categories, the variant isn't being included because only the parent item has the brand associated with it?

    Here is the coupon settings..Coupon showing brand assignment
    And here is the product that the brand is assigned to...
    Hikashop product
    Here is the shopping cart where I tried to apply the coupon...no message appears, but the coupon is not applied...
    Shopping cart with variant product not working
    But I created a test product, without any variants, and re-applied the same coupon code...
    Test product, no variant...coupon applies



    I can confirm that the issue is with variants in Hikashop.  Hikashop does not store the variant product's manufacturer or categories with the individual product variant record...they rely on the parent product to obtain that information.  This is also why (I presume) the category selection doesn't work for us.  We have over 1,000 products and about 800 of these are variants (color, size, etc.).

    So, this is what I started to do but I need your help to see how to complete this.

    In the file /administrator/components/com_awocoupon/helpers/estore/hikashop/couponhandler.php in the function get_storemanufactuer near line 453 I changed:

    $db->setQuery('SELECT product_manufacturer_id AS manufacturer_id, product_id FROM #__hikashop_prod
    uct WHERE product_id IN ('.$ids.')');

    to

    $db->setQuery('SELECT parent.product_manufacturer_id AS manufacturer_id, variant.product_id As pro
    duct_id FROM (#__hikashop_product parent join #__hikashop_product variant) WHERE ((parent.product_id = variant.product_parent_id) and (variant.product_parent_id <> 0)) AND variant.product_id in ('.$ids.')');

    This works with my variant products, but of course it is excluding the items that have no variants and I'm not sure how to adjust this code to include both the original statement (which excludes variants) and my query which only returns variants :(


    Okay, I don't have a clue if this is "correct" but it gets us closer to the results we needed.  We are needing to sell gift cards for the holidays and this is all that I know how to do...I look forward to the correct way of handling this...I ended up using your original db query with one minor change and then merged the resulting object with my query resulting in the coupon/discount being applied to the product based on manufacturer be it a variant or a single product:

        protected function get_storemanufacturer($ids) {
            $db = JFactory::getDBO();   
            $db->setQuery('SELECT parent.product_manufacturer_id AS manufacturer_id, variant.product_id As product_id FROM (#__hikashop_product parent join #__hikashop_product variant) WHERE ((parent.product_id = variant.product_parent_id) and (variant.product_parent_id <> 0)) AND variant.product_id in ('.$ids.')');
            $variants = $db->loadObjectList();
            $db->setQuery('SELECT product_manufacturer_id AS manufacturer_id, product_id FROM #__hikashop_product WHERE product_manufacturer_id <> 0 AND product_id IN ('.$ids.')'); //manufacturer = 0 should be omitted here
            $products = $db->loadObjectList();
            $result = (object) array_merge((array) $products, (array) $variants); //merge db objects from both queries
            return $result;
        }


    --> there may be a single query that would combine variants and single products but I couldn't figure it out and I needed the system to go live this weekend for holiday sales.

    Thank you for your patience and please be kind ... I am not a programmer, just a 'hak'
  • Your avatar
    seyi    
     7 years ago
    0

    Hello,

    Ok, I see the issue now.   The variants do not have the manufacturers or categories causing problems.  Here is the fix for manufacturers:

    <?php
        
    protected function get_storemanufacturer($ids) {
            $db JFactory::getDBO();    
            $db
    ->setQuery('SELECT product_manufacturer_id AS manufacturer_id, product_id FROM #__hikashop_product WHERE product_id IN ('.$ids.') AND product_type="main"');
            $items $db->loadObjectList();
            
            $db
    ->setQuery('
                SELECT p2.product_manufacturer_id AS manufacturer_id, p.product_id
                  FROM #__hikashop_product p
                  JOIN #__hikashop_product p2 ON p2.product_id=p.product_parent_id
                 WHERE p.product_id IN ('
    .$ids.') AND p.product_type="variant"');
            $items2 $db->loadObjectList();
            
            $items 
    array_merge($items,$items2);
            return $items;
            
        
    }
    ?>

  • Default avatar
    opt2bout    
     7 years ago  last edited 7 years ago
    0

    Thanks!  : I can't get a query to work for categories yet.  I know it has to be something similar to joining the table to itself to get the parent item's ID and then querying the category from there, but I don't have a full proof query as of yet.  But switching to brand will work for us today.  I'm surprised no one has noticed variants weren't working before.
  • Your avatar
    seyi    
     7 years ago
    0

    Yes it is surprising, but at least got it working now,  here is category:

    <?php
        
    protected function get_storecategory($ids) {
            $db JFactory::getDBO();    
            $db
    ->setQuery('
                SELECT c.category_id,c.product_id
                  FROM #__hikashop_product_category c
                  JOIN #__hikashop_product p ON p.product_id=c.product_id
                 WHERE c.product_id IN ('
    .$ids.') AND p.product_type="main"
            '
    );
            $items1 $db->loadObjectList();
            
            $db
    ->setQuery('
                SELECT c.category_id, p.product_id
                  FROM #__hikashop_product p
                  JOIN #__hikashop_product p2 ON p2.product_id=p.product_parent_id
                  JOIN #__hikashop_product_category c ON c.product_id=p2.product_id
                 WHERE p.product_id IN ('
    .$ids.') AND p.product_type="variant"
            '
    );
            $items2 $db->loadObjectList();
            
            
    return array_merge($items1,$items2);        
        
    }
    ?>

  • Default avatar
    opt2bout    
     7 years ago
    0

    Thank you!