Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're using the Avone theme alongside the Order Deadline App to provide our customers with Estimated Delivery.
In previous themes when a customer added a product to the cart the Estimated Delivery Date appeared as a line item in the cart and also captured on the order details in admin as it was triggered by the product:added event.
Unfortunately the Avone theme uses the product event but not product:added and whilst I've asked them to add this into the theme.js file they've stated we need to add it.
Can anyone share with me what the code should be please so that I can add it into the file.
Thanks
Lind
Try to add the following code to the theme.js file:
// Add the Estimated Delivery Date event to the Avone theme shopify.on('product:added', function(product) { // Get the estimated delivery date var estimatedDeliveryDate = shopify.orderDeadline.getEstimatedDeliveryDate(product); // Add the estimated delivery date to the cart line item var cartLineItem = document.querySelector('[data-product-id="' + product.id + '"]'); cartLineItem.setAttribute('data-estimated-delivery-date', estimatedDeliveryDate); // Add the estimated delivery date to the order details in admin var orderDetailsForm = document.querySelector('#order-details-form'); var estimatedDeliveryDateField = orderDetailsForm.querySelector('[name="estimated_delivery_date"]'); estimatedDeliveryDateField.value = estimatedDeliveryDate; });
Thank you, I've added the code but what I've found is:
The Line Item doesn't appear unless the cart is refreshed.
We also find that the Cart Drawer disables as a result of adding the code.
can u please tell me how to refresh cart in avone theme, cart:refresh is not working.
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024