I have two scripts for the checkout.
How can I combine them? Only one script can be published in the checkout section in the script editor.
The first script for sorting the shipping solution
desired_order = ["DHL","FedEx","DPD","FedEx Express","DPD Express"]
Output.shipping_rates = Input.shipping_rates.sort_by do |shipping_rate|
desired_order.index(shipping_rate.name) || desired_order.length
end
and a second script to hide the shipping solution when entering a Packstation in the address field.
shippingaddress1 = Input.cart.shipping_address.address1.upcase.split[0...-1].join ' '
checkpobox = ['PACKSTATION','POSTFILIALE','PACK','POST']
puts shippingaddress1
if checkpobox.include?(shippingaddress1)
hideship = ['DPD','DPD Express','FedEx','FedEx Express']
else
hideship = ['NO DPD']
end
Output.shipping_rates = Input.shipping_rates.delete_if do |shipping_rate|
hideship.any? { |hideship| shipping_rate.name.include?(hideship) }
end
Thanks for help