Set free shipping using script editor

Set free shipping using script editor

cferrufino
Shopify Partner
3 0 0

Hello, I would like help with a script.

What I want to achieve is that if a user chooses the "TEST" payment method , the shipping becomes free or is set to 0.

 

I was working on something like this but I have an error when accessing payment_gateways:

 

payment_method_name = "TEST"

if Input.cart.payment_gateways.any? { |gateway| gateway.name == payment_method_name }
Input.shipping_rates.each do |shipping_rate|
shipping_rate.apply_discount(shipping_rate.price, message: "Free Shipping with Credit Card Installments")
end
endOutput.shipping_rates = Input.shipping_rates

 

I understand that since it is a shipping script I cannot access the payment_gateway, right? How could I achieve my goal, I appreciate your help.

Replies 0 (0)