Foxycart discount with a fixed percentage of amount

AkashAkash Member
in Help edited September 2014
Hi all,

I have been trying to set a fixed percentage amount of discount on each products, but somehow I can not see things working.

Here is the link https://wiki.foxycart.com/v/0.6.0/getting_started/adding_links_and_forms that has preety description about how to apply discounts on items with various discount type and method as options.

Here is the situation that are already tried
I am using HMAC for validation, and I put discount option as open -- Doesn't seem to work
I am using HMAC for validation, and put fixed discount value with closed field -- Doesn't seem to work


The problem is, the response does not even show any kind of error in request structure.

Here is the request structure
cart:add
1:name||9c5e8fd6122fd6fb19501e0c4a07222416f547b4402f2aa53ba6bb2f68b76594:WORLDCARD ULTRA PLUS SCANNER
1:price||c1e6de3994ea336f13ba570ebb8503c6393dce80373ec9fb494c0a3d5a67c9f7:252.00
1:quantity||2e0514762f8a78af49465a95232f53f729cabdb1fa82743f925f10d72e359a6f||open:1
1:code||1eb58220946e1224e6bdeb52130743f51dadf748ba7013a101f04a4dc858d98a:924
1:productid||553906b4f27b7c63882fe91c0de7f7c7ca0fbbf02ba3c13c02850894f6e1f090||open:924
1:image||790ff73017ebc2e4f9a358fbe16a95f86eafd77cbf74b380284852dc5b109f3d||open:/image/product-banner/images/ultraplus.jpg
discount_price_amount||eee7370f483665f802a98e46c125a4fa903c443428cf2c5469c4c3cde0618d59:Mega Discount Offer{100-10}:
output:json
fcsid:1i3ugsf68kgaln1a7d61ug80r7
callback:jQuery18204994208326097578_1409808836929
_:1409808844626

And here goes the response of the same
jQuery18204994208326097578_1409808836929({
	"products":[
        {
            "id": "45872649",
            "name": "WORLDCARD ULTRA PLUS SCANNER",
            "code": "924",
            "image": "/image/product-banner/images/ultraplus.jpg",
            "url": "",
            "length": "0",
            "width": "0",
            "height": "0",
            "options": {"productid":"924"},
            "quantity": 1,
            "quantity_min": 0,
            "quantity_max": 0,
            "base_price": 252.00,
            "price_each": 252.00,
            "price": 252,
            "weight_each": 0,
            "weight": 0,
            "shipto": "",
            "category": "DEFAULT",
            "delivery_type": "flat_rate",
            "sub_frequency": "",
            "sub_startdate": "0000-00-00",
            "sub_nextdate": "0000-00-00",
            "sub_enddate": "0000-00-00"
        }
	],
	"product_count": 1,
	"total_item_price": 252,
	"total_discount": 0,
	"total_price": 252,
	"total_weight": 0,
	"total_shippable_weight": 0,
	"session_id": "1i3ugsf68kgaln1a7d61ug80r7",
	"page_referrer": "http://monarch.local/products/office-machines/",
	"custom_fields":{
	},
	"messages":{
		"errors":[],
		"warnings":[],
		"info":[]
	}
});


Any help or pointer to issue would be much appreciated!
Thanks,
Akash.
Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @Akash,

    Thanks for including the detailed post - that helps a lot!

    Could you try prefixing the discount attribute with "1:" as you have the other attributes?
  • AkashAkash Member
    edited September 2014
    Thanks @fc_admin for your quick reply

    I did try with 1:

    Here is the request structure of what I tried
    cart:add
    1:name||9c5e8fd6122fd6fb19501e0c4a07222416f547b4402f2aa53ba6bb2f68b76594:WORLDCARD ULTRA PLUS SCANNER
    1:price||c1e6de3994ea336f13ba570ebb8503c6393dce80373ec9fb494c0a3d5a67c9f7:252.00
    1:quantity||2e0514762f8a78af49465a95232f53f729cabdb1fa82743f925f10d72e359a6f||open:1
    1:code||1eb58220946e1224e6bdeb52130743f51dadf748ba7013a101f04a4dc858d98a:924
    1:productid||553906b4f27b7c63882fe91c0de7f7c7ca0fbbf02ba3c13c02850894f6e1f090||open:924
    1:image||790ff73017ebc2e4f9a358fbe16a95f86eafd77cbf74b380284852dc5b109f3d||open:/image/product-banner/images/ultraplus.jpg
    1:discount_price_amount||eee7370f483665f802a98e46c125a4fa903c443428cf2c5469c4c3cde0618d59:Mega Discount Offer{100-10}:
    

    In Response I get same json callback as given in original post.

    And I thought, that "1:" is not needed, as discount affects all products and not individual in this case. Correct me if I am wrong :)
  • fc_adamfc_adam FoxyCart Team
    @Akash,

    A product level discount, as you're applying - will only apply to the single product it is added against, so you would need to group it with the existing product to ensure it gets applies.

    If you're wanting to apply to a group of products - you can either do that with a category of products with a category level discount, or across a whole order by using a coupon. Product level discounts will only ever apply to a single product.

    In my testing, the discount worked once I prepended the "1:" to the attribute. Do you have an add to cart page we can see?
  • AkashAkash Member
    edited September 2014
    @fc_adam

    First of all, thanks for the detailed explaination, that forced me to read few more links and articles.
    And I do not have a demo url to show, so could not provide it.

    Somehow I figured out the issue.

    All of the products are currently in default category, and I have to add the corresponding Discount Details in FoxyCart Admin panel, that I completely missed out.

    And in default category, whether I append ":1" or I do not, it does not matter.

    So finally discount thing seems to work :)

    This is the link https://wiki.foxycart.com/snippets/discounts from which I came to know that I have change something in FoxyCart Admin panel, else it was never very clear that I have to change few things in Admin panel too.

    Thanks,
    Akash.
Sign In or Register to comment.