Hi, I'm trying to do something in particular only for those line items on cart that are affected by a discount code, but I'm not being able to do it. Based on docs, there's a discounted? property that should pull this off, but it's always returning me false, no matter if the line_item is affected or not.
Has anybody been able to make this happen?
@BradKrane I couldn't replicate your case. Could you provide more information?
Did you discount apply to an order, collection or specific products?
I made fixed amount & % off discounts for a specific product and discount? still returns false for every single discount type for a specific product.
Input.cart.line_items.each do |item| if item.discounted? puts "discounted" else puts "not discounted" end end
@NAVEKI I created a discount code for a fixed dollar amount off of a specific variant then added that and another item to the cart and applied the code at checkout. The item that was discounted's discounted? method responds true after the code application.
@BradKrane I understood that from your last post but I still couldn't replicate your case. Could you provide screenshots or something? Like I said before tried what you said but can't reproduce your functionality. I think you must be doing something else to get discounted? to return a boolean based off of a cart discount - outside of script editor.
I'm interested in your case because I received information from Shopify explicitly stating that the discounted? method only regards line items discount applied through script editor - not storefront applied discounts.
|04-08-2020 05:47 PM|