Switch the shipping rate dynamically in Shopify - shopify

I'm planning a new Shopify project, and the site requires a different shipping cost depending on the postal area of a postcode (e.g. SE1, N7). The plan was to manually add different shipping options inside of Shopify, then AJAX GET /cart/shipping_rates.json, and manually filter to the correct shipping rate by matching the name to postal area.
But my question is -- is there any way to carry over this shipping method to the Checkout as a selected option, and hide the Shipping Method drop-down from the checkout to prevent them choosing a different the shipping cost?
... Or, ideally, is there a way for me to directly override shipping costs through the API?

I don't know of any onboard functionality, which can facilitate this.
But there is a quite hacky workaround, that I use to filter the shipping rates in the checkout page.
Through the "Additional Google Analytics Javascript" field you can sneak a JS on every page of the shop, including the checkout. Here you can basically manipulate the shipping rates as you like.
In your case, the code must be aware of the shipping_address zip code. You can try to set a cookie on the first checkout page and then read the same cookie on the second.

Unfortunately, this isn’t possible with Shopify’s existing checkout.

Related

Shopify - Validate cart items at checkout?

A product in my store (e.g. a fine art print) has a base price of £20 and it has multiple customizable options (size / framing) that are added as additional items to the cart (e.g. Small [£0] / Medium [+£10] / Large [+£20] or Unframed [£0] / Framed [+£10] )
I have to do it this way because some products have more than 3 variant options (Shopify only supports 3)
These additional items that represent the customization options for the base product are added when the customer adds the base product to cart, but the additional products representing options are hidden to the customer in the cart.
At checkout however all is revealed, the base product appears with 2 additional items along with their additional prices. Not ideal but OK!
However, it occurred to me that there's nothing stopping a tech-savvy nerd from grabbing the variant ID of the additional items and sending a POST request to /cart/update.js that removes them from the order during checkout.
The customer just reloads the checkout page and they've just halved the price they have to pay!
I need to prevent this from happening.
I don't suppose there's a way to validate all the items in the cart when the customer requests the checkout page?
If that's not possible, how do other Shopify stores get around this issue?
If you are on the Shopify Plus plan there are two things you can do:
During checkout validation - use Script Editor to check the cart contents and if it's invalid, set the base product quantity and additional products to 0. This will prevent customers from checking out.
Post checkout validation - use Shopify Flow to cancel the order after it's placed and if it's invalid
But that's a lot of development, especially when you are not familiar with it, it will be hard to go through and make it work as expected (covering all edge cases). It's possible to create a such script but analysis of all possible scenarios and writing a code for it will take some time. If I were you I would consider an app that creates bundles as a single item. Adding such a bundle to the cart takes a few seconds to process as the app is making some admin API calls in the background but it solves your problem. I cannot promote any paid solution on StackOverflow but you will easily find something - there are plenty of solutions in the app store.
The decision comes down to your estimation + possible change requests and fixes vs. the cost of the app on a yearly basis

How can I get tax details from my personal webserver and display on the checkout page in shopify?

I want to create a shopify app that can fetch tax and HS code details from my website and display that to checkout page of the user as soon as user adds a product to cart. How can I build this?
You can use an App Proxy at the cart level to show off information. The proxy serves as a secure way of contacting your server and returning results. In checkout itself, you can offer up information too, with checkout scripts post-purchase.
Note that without integrating a tax service into Shopify itself and using that, none of the tax data or numbers you show off will have any use in the actual order calculations, meaning all your work is simple convenience of showing off an estimation to customers. The tax numbers the customers may actually see will be done by Shopify and/or the integrated tax solution your merchant account uses.

Shopify changing product price for variation by app

I am a shopify partner, I am trying to get around the the variant limits of shopify by coding an app and also because my client has a complicated formula for calculating the price. I don't have a problem with the part that adds the information for my variants to the order, however when I want to modify the price based on the user selection, it doesn't seem an easy task to do.
I came across couple of apps which does the same thing by adding a new product or variation which is not optimal for my use case, is there any app that does the job without adding extra information to the database, if so, how?
Qualified Yes
Unfortunately, Shopify doesn't give us a lot of options to edit prices of items dynamically. Here are the two options that I know of that will allow you to adjust the price of a product directly - however, both have limitations.
Using Shopify Script Editor
If you're working with a Shopify Plus merchant, you can use the Shopify Script Editor to dynamically adjust the prices of products, provided that the direction you adjust is down. You cannot increase the price of a product using the script editor - so for your use case, the list price would have to be the most expensive possible price that the item sells for, which you would then discount appropriately using the app.
Using draft orders
Using an app, you can use Shopify's Draft Order API to create an order with custom discounts and/or create completely custom items that are independent of the products set up in the product database.
The basic flow for this is that when the customer clicks 'checkout' you halt the normal navigation, send the cart contents to your app, create a draft order with the appropriate pricing, then supply the front-end code with the draft-order checkout/invoice URL so that you can send the customer there instead of the normal checkout. This has several limitations, however, including that prices of existing products can only be discounted, not increased, and the fact that Shopify will not allow a customer to use discount codes on a draft order invoice - once an order is set up this way, Shopify's assumption is that all prices are final.
Disclaimer: Sorry if someone sensible doesn't like a response with a link :) I'm not related to this app I'm just a user.
On a project with complex pricing, we use the app Wholesale Pricing Discount by Wholesale Helper we liked because is easy to import multiple pricing by-product and relate it by customer.
this app does not multiply the products, they use customer tags. maybe that can give you some guidance.
An important rule on Shopify is you can't increase the price by API on an order, you can just reduce i

Method for letting customers add additional personal information (ex: default size) in Shopify?

I'm a first-time Shopify developer looking for a way to let customers enter additional data about themselves in Shopify. Specifically, I'd like to add a page or modify the account info page so the customer can enter measurements. I'd then like to take that measurement information, process it, and return a recommended size for products in the shop.
Is this possible in Shopify? I am trying to figure out how to add metafields for customers to record their measurements, but I'm a bit lost.
This should work, but would require a fair bit of customization on the merchant's part and is a bit of a hack:
When a customer is logged in their info is available through Liquid.
This allows you to reference that customer's data when rendering shop pages, e.g. a Product page.
You can assign Metafields to customers using the API. These are also available through Liquid.
Putting this all together, you can have a form on the shopfront asking the customer for info once they're logged in. The form submits to your server where you add the info to the Customer object as Metafields using the API. Then you have some clever Liquid on the Product page that either does the necessary calculations itself or embeds the relevant info into javascript to be processed client-side.

Applying a discount code to a specific product in Shopify

I've been working on setting up a Shopify store. One major feature they don't have built in is being able to provide a discount to a specific product, even though it looks like people have been requesting it since 2008!
Does anyone have any idea how this could be accomplished with their API?
Thanks!
Shopify allows you to offer product-specific discounts. On your Shopify Admin / Dashboard go to Discounts. Click on Add a discount:
On the Discount type section make sure to choose the Specific product from the dropdown:
Click on Save and you're all set. On your discounts list you'll see the generated discount with the conditions along with the product name:
Unfortunately, the Shopify API doesn’t offer product-specific discounts yet. It’s definitely in the pipe, but the feature is not available yet.