Testing LineItem.properties in Script Editor

Highlighted
Shopify Partner
1 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
Highlighted
Shopify Partner
17 2 5
Did you ever find a solution?
0 Likes
Highlighted
Tourist
4 0 4

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.