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.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024