Ecommerce Shopify WordPress Discussion

Shopify Ruby Script Error – discount code requirements not met (empty cart)

I am working on a script that would block promo code usage for products that are tagged with 'sale' - I am seeing an error message on line 1 of my script and I'm not sure how to resolve it. The script otherwise functions fine and works as expected. Any suggestions on how to resolve this error? # ================================ Customizable Settings ================================ # ================================================================ # Define the tag for products where discounts are not allowed. # ================================================================ SALE_TAGS = ['sale', 'Sale'] # Tags used to identify sale products REJECTION_MESSAGE = "Discount codes can't be used with Sale products" # ================================ Script Code (do not edit) ================================ # ================================================================ # ProductSelector # Finds matching products by the entered criteria. # ================================================================ class ProductSelector def initialize(tags) @tags = end def match?(line_item) product_tags = (@tags & product_tags).any? end end # ================================================================ # DisableDiscountCodesForProductsCampaign # If any matching items are in the cart, the discount code is rejected. # ================================================================ class DisableDiscountCodesForProductsCampaign def initialize(tags, message) @product_selector = @rejection_message = message end def run(cart) return if cart.discount_code.nil? if cart.line_items.any? { |line_item| @product_selector.match?(line_item) } cart.discount_code.reject(message: @rejection_message) end end end # ================================================================ # Campaign Execution # ================================================================ campaign =, REJECTION_MESSAGE) Output.cart = Input.cart
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.