Hi
I have added the below line item script which
-
Checks if the customer is logged in
-
Checks if the customer has a particular tag ‘VIP’
-
Checks the product is not a gift card/not on sale/includes a tag ‘VIP’
Then applies a 10% discount
I have the following outcome on the frontend
-
Customer is logged in with correct tag => Discounts applied correctly
-
Customer logs out => Discounts removed immediately as expected
-
Customer logs back in => Discounts do NOT reappear (the discounts only appear again after the customer adds or removes something from the cart)
Is this the expected behaviour? Why would the script run correctly/immediately when a user logs out but not when they log back in? If so, how can I force the script to run again?
customer = Input.cart.customer> if customer> if customer.tags.include? ‘VIP’> Input.cart.line_items.each do |line_item|> product = line_item.variant.product> next if product.gift_card?> next if line_item.variant.compare_at_price> next unless product.tags.include? ‘VIP’> next unless customer> line_item.change_line_price(line_item.line_price * 0.90, message: “BFF Discount”)> end> end> end> > Output.cart = Input.cart