Shopify Ajax Add to Cart Function Isn't Updating In Real Time

Eli-O
Excursionist
15 0 5

I have a custom Shopify theme I've made in Webflow and Transfer it over to Shopify via Udesly Adapter.

It works pretty well and I'm working on adding a "bundle" functionality.

The webflow element is relevant because I've added the script code on the sidebar tied to the page.

Screen Shot 2021-04-08 at 5.27.34 PM.png

I created a button with a button ID and I'm targeting it with that code. Here it is in plain text:

 

<script>
(function clickMe() {
  const button = document.getElementById("add-to-cart-test");
  button.addEventListener("click", event => {
    $.post('/cart/add.js', {
  items: [
      {
    quantity: 3,
    id: 34141373857837,
  },
  {
    quantity: 2,
    id:37205159739552
  }
]
});
    alert("button clicked");
  });
})();
</script>

 

It adds the products to the cart but then the user has to reload the page to see any effect.

 

I need help

 

1. Getting this to update in real time

2. Is it possible to add these products along with a discount?

Seth_Roger
Excursionist
39 1 3

Hello,

PM Sent, please check.

Best Regards!

Seth R

ronw
Tourist
5 0 1

Hello @Eli-O 

Hope you are doing well!

I have sent you PM , Please check.

BR
Ron

Dear @Eli-O 

We will be happy to help you. Please contact at task4store@mswebdesigner.com

Best Regards
MS Web Designer| MS Web International | Task4Store
Contact Us: https://www.task4store.com/pages/contact-us OR task4store@mswebdesigner.com
Was our reply helpful? Please Like or Accept solution
Jennifer20
Navigator
545 18 20

Hi @Eli-O 

I hope you're doing great!

I would be happy to work with you. Please give me a suitable time to discuss your requirements.

Also, add me over Skype id- live:jennifer.wcoast or Email- sales@wreximinfotech.com

I look forward to your response!

Stay Well

Thanks!

DeepVyas
Shopify Partner
531 5 7

Hi , 

I can assist you on both the points 

Please connect further 

Regards

Deep 

Shopify Expert | S: deepvyas71 | E: deepvyas71@gmail.com
Eli-O
Excursionist
15 0 5

Update: Someone is working on this but it is not done yet.

0 Likes
HymnZ
Trailblazer
358 1 42

@Eli-O easy way to get #1 going is to link it with an existing update function.

#2 though is not possible without getting into the app side of things.

My specialty lies in making Shopify work for your requirements, not the other way round. HMU on email: hymnz@outlook.com or on skype: hymnzzy
Eli-O
Excursionist
15 0 5

Yes, we've setup some code to work but there are some issues with a loop, it adds sometimes just one, other times the whole bundle.

Then for the discounts it works from testing and "automated discount" on the shopify side and we will get into the app.

Current issues is that the Ajax cart does not update the "discounted price" in real time. It does add the bundles now, but not the discounts.

0 Likes
HymnZ
Trailblazer
358 1 42

@Eli-O  check DM please.

My specialty lies in making Shopify work for your requirements, not the other way round. HMU on email: hymnz@outlook.com or on skype: hymnzzy
0 Likes