Shopify Scripts: Increase line item quantity and reduce price to zero

Highlighted
New Member
3 0 0

Hi all,

I noticed that when i increase the quantity of a line item then reduce it's price to zero the price reduction only applies to the original quantity and not the adjusted one. 

Am i missing something here?

 

def adjustQuantity(line_item, quantity)
  # if the line item quantity isn't the same as the quantity specified in the bundle
  if line_item.quantity != quantity
   # set the quantity from 1 to 2
    line_item.instance_variable_set(:@quantity, quantity)
    # price reduced for the initial quantity of 1 only and not for 2
    line_item.change_line_price(Money.zero, message: 'Bundle item')
  end
end

 

Thanks!

0 Likes