I have a normal quantity selector with +/- buttons and a customer can also type in the desired number. Additionally I’d like to add buttos with pre-defined pack sizes like 5pcs and 10pcs. When clicked a button the quantity selector number should update accordingly. I’d like to do that with a custom liquid code added on the product page if possible?
I have discount calculation working and I’d like to have line to show total price of the quantity selection on the product page. I’d like to do that also with liquid code on the product page if possible.
So for example:
unit price 20€
if 5pcs selected in the quantity selector a discount is automatically calculated and the unit price is updated to 15€
I’d like to have a line to show to the customer: Total price: 5pcs = 75€ which should update always when the quantity is changed.
To implement these custom functionalities on your Shopify product page using Liquid code, you’ll need to edit the product template file. Here’s a guide on how to achieve each of the requested features:
1. Adding Buttons for Pre-defined Pack Sizes:
You can add buttons for pre-defined pack sizes and use JavaScript to update the quantity selector accordingly. Here’s how you can do it:
Edit the Product Template:
Go to your Shopify admin dashboard and navigate to Online Store > Themes.
Click on “Actions” next to your theme and select “Edit code.”
Find the product template file (usually named “product.liquid”) under the “Sections” or “Templates” folder.
Add HTML for Pack Size Buttons:
Add HTML buttons for pre-defined pack sizes below the quantity selector. For example: