Testing LineItem.properties in Script Editor

rlh
Shopify Partner
2 0 0

Hi folks,

 

I'm trying to write some functionality that reads and reacts to line item properties, set during the add-to-cart process.

 

However, in the script editor environment I can't see a way to set such properties on the Cart Input line items. Instead I have to keep publishing, running a live checkout, and unpublishing the script as I work, which is painfully slow and prevents me seeing script console output.

 

How can I set properties in the Script Editor test cart input?

0 Likes
leighb4rnes
Shopify Partner
17 2 6
Did you ever find a solution?
0 Likes
valespring
Tourist
4 0 5

Wanted to chime in for anyone finding this later. Yes, unfortunately Shopify doesn't allow you to add item properties for testing. This is one of those "gaps" that I hope they close in the near future.

 

Anyways, what I've decided to do for testing is write a function to add these properties for testing that initializes before my other checks.

 

  def set_pseudo_properties(cart)
    cart.line_items.each do |item|
      example_prop_one = {@example_key_one => 'One' }
      example_prop_two = {@example_key_two => 'Two' }
      
      new_properties = example_prop_one.merge(example_prop_two)

      item.change_properties(new_properties, { :message => "" })
    end
  end

Then, afterwards, I will set my other function that checks for properties to properties_was.

kercambre
Shopify Expert
3 0 2

Thanks for this little hack. Very unfortunate not to be able to add it through the Input Panel though.

0 Likes
gogoanime
New Member
1 0 0

If you are looking for a script editor feel free to reach out to me via below sites

 

Yehrishtakyakehlatahai

gogoanime

kissanime

0 Likes