Shopify Scripts: Can we increase shipping rates in shopify using shopify script?

Solved

Shopify Scripts: Can we increase shipping rates in shopify using shopify script?

crpatel
Shopify Partner
18 0 3

I found similar question in the stackoverflow, and from this answer I come to know about Career service. Which looks promising initially, but after reading the doc from here, I found that there is an issue for my use case.

This is my use case:

  • There will be multiple items in the cart with different delivery dates set(I store delivery dates in the line_item property)
  • now when user go to checkout the shipping rate has to be calculated based on the delivery dates(which are stored in the line item property for each line item)
  • shipping price should be calculated like ...... if there is only one delivery day, we need to offer x price, if there are two different delivery dates we need to offer 2x price and so on....

so the issue is, Carrier Service uses Server side cashing and it will only ask for price if any of these(variant IDs, default shipping box weight and dimensions, variant quantities, carrier service ID, origin address, destination address, item weights and signatures) field change. It doesn't include line item properties(where I have stored delivery dates).

I have also checked the shopify scripts from here, but after some mockups I come to know that we can only provide discount to the existing shipping rates and can not add new shipping method, or increase shipping price for existing shipping method.

Please help me to find a solution for this problem.

Accepted Solution (1)

PaulNewton
Shopify Partner
7721 678 1620

This is an accepted solution.


@crpatel wrote:
  • shipping price should be calculated like ...... if there is only one delivery day, we need to offer x price, if there are two different delivery dates we need to offer 2x price and so on....

 


Alternative do this as a fee , add a productVariant set to the fee price.

 


I have also checked the shopify scripts from here, but after some mockups I come to know that we can only provide discount to the existing shipping rates and can not add new shipping method, or increase shipping price for existing shipping method.

 

Set the shipping rates to be a high enough rate to cover any possible shipping cost then discount it down to what's in the checkout, reject checkouts that go outside possibility and log it or other process to handle customer remediation. 

You may need to modify checkout.liquid to hide shipping prices until the appropriate time as to not scare off customers.

 

A hack is to use weight based shipping rates and set variants to specific weights or add a product whose only purpose is to qualify the order to a minimum shipping weight.

 

 

I'd also contact the Plus stores MSM to let them know of this use case for checkout-scripts being able to INCREASE shipping rates.


 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


View solution in original post

Replies 6 (6)

PaulNewton
Shopify Partner
7721 678 1620

To clarify you are to see the item properties field in the shopify request for rates to your carrier-service endpoint?

 

But this hits an issue when/if a customer goes back to cart and makes changes that alter the line-item-properties(LIPS)?

Server-side caching of requests

Note how the docs on request cache'ing goes over situations that can create new requests bypassing cache'ing.

When any of following properties change:

  • variant IDs
  • default shipping box weight and dimensions
  • variant quantities
  • carrier service ID
  • origin address
  • destination address
  • item weights and signatures

When a system is silly like that invent a situation that creates a new request.

Just make one of those fields change:

  1. create customer specific product/variants
  2. add a dynamically generated utility product to the cart  that is unremovable (call it "Delivery Date - Product Name" or something so it makes sense when it appears in the line items to customers in cart, checkout and notifications)
  3. spool up a different service for a new ID (remember it has to happen fast enough to not hit the carrier service response timeouts)
  4. add a salt to address info
  5. if an box api is  ever available just cycle a boxes dimensions to basically disable the cache
  6. etc

 

If your working on a Plus store also contact the MSM for that Plus store and make a request there needs to a direct method in such API's to turn off cach'ing. It's silly when such systems don't already have a documented opt-out.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


kamenche
Shopify Partner
3 0 0

Hi @PaulNewton 

How can you make a product in the cart unremovable?

I don't need a full walk through, just some direction. Is this a property on line items I can set to true?

PaulNewton
Shopify Partner
7721 678 1620

@kamenche if they remove the item add it back to the cart, dont allow checkout if item not in cart.

 

To be clear there is NO read-only system for cart items in the ajax-cart api; the closest is cart-permalinks draft-orders that go right to checkout and don't really have a "cart" step.

You have to create the frontend|backend logic to emulate that behavior. 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


kamenche
Shopify Partner
3 0 0
PaulNewton: thanks, that's really helpful!

I used Liquid/JS on the main-cart.liquid file (via a custom snippet added
at the bottom) to check whether a product (with a specific tag) was in the
cart.

And then to add a specific product by variant ID (special "fee" product).

It works, but annoyingly it only works when either I reload the cart page
or click to go to checkout.

I effected the "can't remove" functionality by wrapping the html elements
for the + / - / remove buttons in the cart in an "unless line item has tag"
logic.

This worked, but again, the fee product only shows up after refresh or
clicking to go to checkout....

What's the place to put this logic so that the action occurs as someone
goes to the cart the first time?

Thanks again!

PaulNewton
Shopify Partner
7721 678 1620

This is an accepted solution.


@crpatel wrote:
  • shipping price should be calculated like ...... if there is only one delivery day, we need to offer x price, if there are two different delivery dates we need to offer 2x price and so on....

 


Alternative do this as a fee , add a productVariant set to the fee price.

 


I have also checked the shopify scripts from here, but after some mockups I come to know that we can only provide discount to the existing shipping rates and can not add new shipping method, or increase shipping price for existing shipping method.

 

Set the shipping rates to be a high enough rate to cover any possible shipping cost then discount it down to what's in the checkout, reject checkouts that go outside possibility and log it or other process to handle customer remediation. 

You may need to modify checkout.liquid to hide shipping prices until the appropriate time as to not scare off customers.

 

A hack is to use weight based shipping rates and set variants to specific weights or add a product whose only purpose is to qualify the order to a minimum shipping weight.

 

 

I'd also contact the Plus stores MSM to let them know of this use case for checkout-scripts being able to INCREASE shipping rates.


 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


crpatel
Shopify Partner
18 0 3

@PaulNewton 

 

Thanks

I have done exactly this.

 

added a max possible shipping rate and provide discount to that shipping rate as per requirement using the scripts. 

Didnt need to modify the checkout, as before anything appear on the checkout the script has already been applied and it shows the correct price.