cust_disc = 0
cust_dist_msg = "test"
item_val = line_item.properties
if item_val.has_key?("customer_Discount_Rate")
cust_dist_msg = item_val.has_key?("customer_Discount_Rate") - TRUE (working)
cust_disc = item_val["customer_Discount_Rate"] - Not working
end
end
DISCOUNTS_FOR_CUSTOMER_TAG = [
{
customer_tag_match_type: :include,
customer_tags: ["wholesale"],
discount_type: :percent,
discount_amount: cust_disc,
discount_message: cust_dist_msg,
},
]
remaining code is same as in the reference link..
Any help pointing in the right direction would be appreciated.
How are you logging the value? I just tested with an "example" line item property, to create a custom message:
Input.cart.line_items.each do |line_item| if line_item.properties.has_key?("example") line_item.change_line_price(line_item.line_price * 0.90, message: line_item.properties["example"]) end end Output.cart = Input.cart
Added to cart like so:
jQuery.post('/cart/add.js', { items: [ { quantity: 1, id: ..., properties: { 'example': 'hello' } } ] });
I've created a line item property(customer_Discount_Rate) on the cart page.
Could you be creating cart attributes, instead of line item properties?
User | Count |
---|---|
12 | |
12 | |
10 | |
7 | |
6 |