This document outlines the process to show certain shipping rates to specific customer groups such as a Wholesale Customer Tag while hiding them from others such as your Retail Customer Tag on your Shopify store using a VIP shipping customer tag.
On This Page
Before you begin, please ensure you have the following:
- ShipperHQ installed on your Shopify Plus store
- Access to the Shopify Script Editor
- Shipping rates configured in ShipperHQ for your standard and VIP customers
- The Script Editor app installed from the Shopify App Store
For this example, ShipperHQ has a table rate carrier setup with two shipping methods: Standard (method code is delivery) and VIP (method code is delivery_vip). We also have a customer tag in Shopify of VIP.
How to Create Script in Shopify Script Editor
- Log into your Shopify Plus admin store.
- Navigate to the Apps > Script Editor dashboard.
- Click the Create Script button.
- Select any script category.
- Click Create Script from the modal dialog.
- Change the Title of your script.
- Leave the Channels set to Online Store and Storefront API channels
- Click the Code tab.
- Paste the following script inside Ruby source code:
VIP_CUSTOMER_TAG = 'VIP' VIP_SHIPPING_METHOD = "delivery_vip" if !Input.cart.customer.nil? and Input.cart.customer.tags.include?(VIP_CUSTOMER_TAG) Output.shipping_rates = Input.shipping_rates.delete_if do |shipping_rate| !shipping_rate.code.end_with?(VIP_SHIPPING_METHOD) end else Output.shipping_rates = Input.shipping_rates.delete_if do |shipping_rate| shipping_rate.code.end_with?(VIP_SHIPPING_METHOD) end end
- Click the Save and publish button.
- Tag a customer with the VIP tag.
- Go to your Shopify Plus storefront.
With the setup described above, what’s happening is that ShipperHQ is returning two shipping options but the script is being used to hide one or the other option based on the customer’s Customer Tag. If the customer has a Customer Tag of “VIP”, the script hides all shipping methods other than “VIP” and if the customer has a Customer Tag other than “VIP, the script hides the “VIP” shipping method.
Fo debugging, you can use Input tab to modify input parameters. In the script, you can use puts to dump objects to the Console (located below Ruby source code field). Then click Run script in the Output panel to see the results.