Help please coupon setup: get product added for free to cart for each $100 spend


  • Default avatar
    etrader    
     2 months ago
    0

    Hello dear sir,


    I am not able to configure this correctly for a while.

    For a promotion in my store, customers are to receive a specific selected product (value $28) for free for each $100 spend in the store. It means they get two of the specified product when spending $200.

    The free product needs to be shown in the cart together with the discount shown.

    Can you please tell me if this is possible. I have been battling with this for a while :(.


    Thanks so much for your assistance.


  • Your avatar
    seyi    
     2 months ago
    0

    Hmm, if it was just 1 product total added to the cart, then you could use a buy x get y coupon:

    Function type: buy x get y
    Value: 100%
    Minimum order total: 100 specific
    Maximum discount qty: 1
    Buyx
        Number: 1
        Type: product
        Exclude the free product
    Gety
         Number: 1
         Type: product
         Include the free product
         Check: Automatically add to cart 'Get Y' product

    And that would do it.

    To add for 200, 300, 400...etc, you would have to create the different coupons for them, then add them all to a 'combination' coupon ordering from highest value to lowest, and set process type to 'first found match'

    Then use the parent coupon.
  • Default avatar
    etrader    
     2 months ago
    0

    The second method described works, this is fantastic!


  • Default avatar
    etrader    
     2 months ago
    0

    A little too early. The coupon and product insertion works. Subsequently trying to checkout is generating an error.


    vmTable store

    insertObject

    Could'nt create order


    Several customers reported this and I was able to reproduce it also. I disabled all AWO coupon plugins in the back-end and the checkout goes through normally. Please help. I also reported this to the VM developer.

  • Default avatar
    etrader    
     2 months ago  last edited 2 months ago
    0

    The VM error log shows the string to put in the VM database order coupon field is too long:


    ERROR vmError: vmTable store insertObject #__virtuemart_orders Data too long for column 'coupon_code' at row 1 INSERT INTO `kfuhj_virtuemart_orders`


    Wants to add:  img src=\"/media/com_awocoupon/images/x-48.png\" alt=\"x\" style=\"height:14px;\" /></a>\rMYCOUPONNAME</div>\r


    but 32 characters is the limit for the coupon field when I am looking at the VM database in phpmyadmin.


    Please help.



    PS oddly this happens not everyt ime.
  • Default avatar
    etrader    
     2 months ago
    0

    The VM developer extended the coupon field from 32 to 48, I hope that resolved it, although maybe the references to the awo coupon image is not contributing to the stability.  Thanks for your attention.
  • Your avatar
    seyi    
     2 months ago
    0

    Go to admin > awocoupon > configuration > advanced tab, and update the length, field:

    - Coupon code size in #__virtuemart_orders column coupon_code

    Set it to your current coupon_code size, which is 32.  The data will be truncated to 32 when updating virtuemart.
  • Your avatar
    seyi    
     2 months ago
    0

    etrader @ Feb 23, 2024, 3:05:45 PM
    The VM developer extended the coupon field from 32 to 48, I hope that resolved it, although maybe the references to the awo coupon image is not contributing to the stability.  Thanks for your attention.

    48 is too small, when dealing with multiple coupons I would have made it at least 255.  Then just update that option with the actual length so it knows exactly where to truncate.
  • Default avatar
    etrader    
     2 months ago  last edited 2 months ago
    0

    Mmm OK I did that. The error changed but still an error:


    vmError: vmTable store insertObject #__virtuemart_orders Data too long for column 'coupon_code' at row 1 INSERT INTO `kfuhj_virtuemart_orders` (`virtuemart_order_id`,`virtuemart_user_id`,`virtuemart_vendor_id`,`order_note`,`order_number`,`order_pass`,`order_create_invoice_pass`,`invoice_locked`,`customer_number`,`order_total`,`order_salesPrice`,`order_billTaxAmount`,`order_billTax`,`order_billDiscountAmount`,`order_discountAmount`,`order_subtotal`,`order_tax`,`order_shipment`,`order_shipment_tax`,`order_payment`,`order_payment_tax`,`coupon_discount`,`coupon_code`,`order_discount`,`order_currency`,`order_status`,`user_currency_id`,`user_currency_rate`,`user_shoppergroups`,`payment_currency_id`,`payment_currency_rate`,`virtuemart_paymentmethod_id`,`virtuemart_shipmentmethod_id`,`ip_address`,`order_language`,`STsameAsBT`,`paid`,`o_hash`,`created_on`,`created_by`,`locked_by`) VALUES ('0','72','1','','ADQV0475','p_jxWrww5w','0tWunFqk','0','MAeb0a191','143.513509999','167.01351','29.766811735','{ \"1\": { \"virtuemart_calc_id\": 1, \"calc_name\": \"VAT 21%\", \"calc_value\": \"21.0000\", \"result\": 29.766806635 } }','0','0','138.02769','28.98582','3.719008264','0.780991735','0','0','-28','
    \r \rx\r COUPONNAME
    \r ','0','47','P','47','1','2','47','1','4','3','2xx','en-GB','1','0','36f4e0d23021c8218e86083ae383e50c','2024-02-23 20:23:12','72','0')
    vmError: Couldn't create order
  • Default avatar
    etrader    
     2 months ago
    0

    Even when I put truncate to 12 or something very short.
  • Default avatar
    etrader    
     2 months ago
    0

    It seems a whole link is trying to be stored to the coupon field:

    https://www.mydomain.com/cart?task=deletecoupons&task2=deletecoupons&id=9  (the X showing in the message above).
  • Your avatar
    seyi    
     2 months ago
    0

    Hmm, that does not make any sense.  In awocoupon, there is only one place the virtuemart_orders, column coupon_code is updated.  And it is updated according to the max length you setup in admin and the raw codes, not full html.  Which makes me think this some kind of plugin.  Need more information on this, an error trace.  Need to know what page and line number this error gets thrown on to debug.

    Alternatively you could just make the coupon_code a "TEXT" field, and it would accommodate for these entries.


  • Default avatar
    etrader    
     2 months ago
    0

    Could the coupon variable be filled with the HTML and causing VM not to be able to save it? I am without this error after removing the HTML linking the X to https://www.mydomain.com/cart?task=deletecoupons&task2=deletecoupons&id=9 from the default.php.
  • Your avatar
    seyi    
     2 months ago
    0

    Are you using a one page checkout?  Maybe that is having an effect on it.  To get rid of the html completely you can do this:
  • Default avatar
    etrader    
     2 months ago
    0

    Only pure virtuemart with native virtuemart "one page checkout" enabled.  And yes, that solution helps.
  • Default avatar
    jeremy4    
     a month ago
    +1

    seyi @ Feb 24, 2024, 11:02:24 AM
    [...] virtuemart_orders [...]


    I believe the issue is introduced in the finalize_coupon  and cart_coupon_delete functions in class-awocoupon-helper-estore-virtuemart-discount.php file.

    The function finalize_coupon will generate the HTML version of the coupon including the remove button. This value is stored in the session.


    The coupon is then retrieved from the session with all the HTML

    $coupon_session = $this->session_get( 'coupon', '' );
    and stored in the cart with the whole HTML

    $this->o_cart->couponCode = $coupon_code;

    $this->o_cart->setCartIntoSession();

    Finally, when the order is created by Virtuemart, the coupon will be retreived from the cart. Since it has all the HTML in is, this will fail at it's larger than the field space (Varchar 32).


  • Default avatar
    jeremy4    
     a month ago
    +1

    I believe the issue was introduced in the latest version of Virtuemart as they made a change in the way coupons are handled in the cart. 
    https://virtuemart.net/news/virtuemart-for-joomla-5


    "$cart->couponCode to $cart->cartData['couponCode'], $cart->couponCode is for internal use of the cart. The reason is that we must check the coupon on any update. So the value in cartData is the entered coupon and the value of the cart is the selected coupon. To clear both values, we have a new function clearCoupon"

  • Default avatar
    etrader    
     a month ago
    0

    What a great community response!!! I hope there will be an update soon.