Overview
You may want to restrict shipping methods from showing for a certain customer group on your Shopify store. For example, if you don’t want to show certain shipping options just to your Retail Customer Group, but you do want them to apply for your Wholesale Customer Group. In this doc, we’ll walk through an example restricting our “VIP” shipping to the VIP customer group.
On This Page
Requirements
In order to set this up you need to have
- Shopify Plus store – and access to the Shopify Script Editor
- Shipping rates configured in ShipperHQ for your standard and VIP customers
Setup
In this example, we have 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
Shopify Plus Store Setup
- Go to your Shopify Plus store admin area
- Install “Script Editor” app from the Shopify App Store
Create Script in Shopify Script Editor
- Go to your Apps / Script Editor and click Create Script
- Select any script category and click “Create Script” inside modal dialog.
- Change the Title of your script and leave the Channels set to Online Store and Storefront API channels
- Switch to Code tab and paste the following script inside “Ruby source code“:
- Click “Save and publish”
- Tag some customer with a “VIP” tag
- Go to your Shopify Plus storefront
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
Now VIP shipping method should only be visible to the customer tagged with the VIP tag:
Other customers should see only “Delivery” method:
Troubleshooting
Fo debugging you can use Input tab to modify input parameters and 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