Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v:2.0:snippets:restrict_shipping_to_specific_map_area [2019/12/12 10:20] – [Generate Google Maps Platform API Key] adam | v:2.0:snippets:restrict_shipping_to_specific_map_area [2019/12/12 10:27] (current) – [Add custom template code] adam | ||
---|---|---|---|
Line 16: | Line 16: | ||
===== Create allowed address area polygon ===== | ===== Create allowed address area polygon ===== | ||
+ | |||
+ | In order to dictate what the supported address zone is, we need to generate a polygon, where each point of the polygon is a set of coordinates. We can use Google' | ||
- Head to https:// | - Head to https:// | ||
Line 56: | Line 58: | ||
===== Build custom shipping code ===== | ===== Build custom shipping code ===== | ||
+ | |||
+ | Now for the fun part - adding the custom shipping code to your store! | ||
- Open your store' | - Open your store' | ||
Line 129: | Line 133: | ||
- Next you'll update the '' | - Next you'll update the '' | ||
| | ||
- | ];</ | + | ];</ |
- The beginning of the snippet should now look something like this:< | - The beginning of the snippet should now look something like this:< | ||
const google_maps_api_key = ' | const google_maps_api_key = ' | ||
Line 143: | Line 147: | ||
[-73.9546793, | [-73.9546793, | ||
];</ | ];</ | ||
- | - Next, you'll need to set the shipping rates and error that is displayed to customers. The snippet above sets a $15 " | + | - Next, you'll need to set the shipping rates and error that is displayed to customers. The snippet above sets a $15 " |
// Shipping is allowed! | // Shipping is allowed! | ||
rates.add(10000, | rates.add(10000, | ||
Line 180: | Line 184: | ||
- Save the configuration | - Save the configuration | ||
+ | ===== Test it out! ===== | ||
+ | |||
+ | At this stage - you've completed all the configuration! You should now be able to add a product to your cart, proceed to the checkout, and enter shipping addresses that are inside and outside of your shippable zone to test it out. |