Script Reporting in Order Timeline

Shopify Partner
1 0 0

I created a shipping script that has a conditional along the lines of

if customer and customer.tags.include?("Active Subscriber")

When the conditional is passed, the customer gets free shipping. The issue I'm having is no matter if the conditional is passed or not, it still reports that this "Free Shipping" was applied in the Order admin timeline report. It's not offering free shipping when the conditional does not pass which is correct, it is reporting so though (e.g. https://screencast.com/t/r8B0y9nelLV). Is there a way to get a shipping script to only report if an action was actually applied (such as a shipping rate modification)?

0 Likes
Shopify Partner
132 1 16

Hi Eddie,

Could you post the full script? I'll be able to get a better idea of what's happening that way.

Cheers,

Elliott

Feeling a bit lost? Contact elliot@mandelbrotian.com for help with theme setup, alterations, custom functionality, and app development.
0 Likes
Highlighted
New Member
1 0 0

Yup, thanks for taking a look!

SHIPPING_HEADER = "USPS Priority - USA Only"
SHIPPING_SUBHEADER = "FREE Member Shipping"
MINIMUM_ORDER_AMOUNT = 99 #dollars required in cart to get discount
customer = Input.cart.customer

if customer and customer.tags.include?("Active Subscriber")
    Input.shipping_rates.each do |shipping_rate|
      if Input.cart.subtotal_price_was >= (Money.new(cents:100) * MINIMUM_ORDER_AMOUNT)
        shipping_rate.change_name(SHIPPING_HEADER, { message: SHIPPING_HEADER })
      end
      shipping_rate.apply_discount(shipping_rate.price, message: SHIPPING_SUBHEADER)
      break
    end
end

Output.shipping_rates = Input.shipping_rates

 

0 Likes
New Member
2 0 0

Was there ever a resolution to this?  I have the same issue and would love to hear the solution.

0 Likes