This document outlines the process to show certain shipping rates to specific groups such as a Wholesale Customer Group while hiding them from others such as your Retail Customer Group on your Shopify store using a VIP shipping customer group.
On This Page
Before you begin, please ensure you have the following:
- 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 group 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.
- Now the VIP shipping method is only visible to the customer tagged with the VIP tag:
Note, other customers only view “Delivery” 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.