Forum

The forum is a free service supported by community members. Please consider opening a support ticket if you need timely help.

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 18 Dec 2017 09:31 PM by  Steve L
create discount where offer free item based on order total
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages


New Member


Posts:
New Member


--
11 Dec 2017 09:48 PM

    We'd like to offer a free water filter if a customer places an order of $150+. We don't care what the customer buys to get to $150, but for inventory tracking, we want to make sure the water filter is added to the cart before the coupon can work.

    I can either create a promo coupon where product requirement is set to allow all (see below) but then the coupon doesn't force the filter to be in the cart:

    or if I try to switch that and say allow only and add the filter (see below) then the coupon this way means that if any other product other than the filter is added to the cart the coupon does not work!



    I have also tried it with a promotion which makes sure the filter is in the cart, but the way below makes EVERY filter free, we just want to allow 1 filter free.



    I am guessing there may be a way to custom code it in the promo (which we've used before to force minimum and maximum amounts) but I am not sure how to take our custom code that enforces minimum amounts and also make sure a filter is in the order. Here is a sample of our custom promo code enforces on sales order detail:

    <xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <out>
    <discountAmount>
    <!-- Coupon code is always tested in lowercase -->
    <xsl:if test="in/salesOrder/couponCodes[couponCode = 'thanks7'] and (in/this/salesOrderDetail/productVariantExtension/data/qualified or in/this/salesOrderDetail/productVariantExtension/data/qualified1 or in/this/salesOrderDetail/productVariantExtension/data/qualified2) and sum(/in/salesOrder/salesOrderDetails/salesOrderDetail/(price * quantity)) >= 99 and sum(/in/salesOrder/salesOrderDetails/salesOrderDetail/discountAmount) = 0">
    <xsl:value-of select="-7.0000"/>
    </xsl:if>
    </discountAmount>
    </out>
    </xsl:template>
    </xsl:transform>

    If anyone can help me put these pieces together I'd greatly appreciate it!

    Thanks in advance!

    0


    Veteran Member


    Posts:2952
    Veteran Member


    --
    18 Dec 2017 09:31 PM

    Hi Jody

    The Storefront currently cannot automatically add a product to the customer's cart using a coupon. The customer must manually add the product first and you can heavily advertise this on your site maybe via a banner to explain the steps to the customer.

    As for the custom promotion rule, I modified your rule slightly. I'm not sure what the data qualified 1,2,3 are for but I omitted them to keep the example short (you can put them back). If you look at the example below, you want to discount $7 when you detect the coupon, when the sales order detail line item being looked is the product variant ID 99 (change this to match the water filter variant ID) and the sub total amount is $150 or more. I didn't test but it would look something like that. I hope this helps.

    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:template match="/">
    <out>
    <!-- Coupon code is always tested in lowercase -->
    <xsl:if test="in/salesOrder/couponCodes[couponCode = 'thanks7'] and sum(/in/salesOrder/salesOrderDetails/salesOrderDetail/(price * quantity + discountAmount)) >= 150 and in/this/salesOrderDetail/productVariantID = 99">
    <discountAmount>
    <xsl:value-of select="-7.0000"/>
    </discountAmount>
    </xsl:if>
    </out>
    </xsl:template>
    </xsl:transform>

    0
    You are not authorized to post a reply.