Trouble running campaign in Script Error

Solved
Highlighted
Shopify Expert
57 1 4

I'm trying to run a campaign in the Script Editor but have been running into this error:

 

[Error] undefined method 'run' for #<ApplyDiscountCodes:0x7f8ecfcc52b0>

 

I can only assume that I'm missing some fundamental syntax or rule but I cant identify whats going wrong with this basic script:

 

 

class ApplyDiscountCodes
  puts "Apply Discount codes"
end

CAMPAIGNS = [
  ApplyDiscountCodes.new(),
]

CAMPAIGNS.each do |campaign|
  campaign.run(Input.cart)
end

Output.cart = Input.cart

 

 

Also how do I prevent 'ApplyDiscountCodes' from running initially and instead waiting to be run through the CAMPAIGNS.each do function?

0 Likes

Success.

Shopify Expert
57 1 4

I've discovered that the campaign needs def run(cart) eg.

 

class ApplyDiscountCodes
def run(cart) puts "Apply Discount codes"
end end

 

0 Likes