hi I want to make a product that is dynamic in pricing use case would be a donation product price that can be custom defined by the customer or want to add an additional 1% cost to the cart total
Hello @DevTeamBevy
Custom script
One way is to use a custom script. This script will allow you to dynamically set the price of the product based on the customer’s input.
Here is an example of a custom script that you can use to dynamically set the price of a donation product:
function setDonationPrice() {
// Get the product price.
const productPrice = product.price;
// Get the customer's donation amount.
const donationAmount = parseInt(prompt("How much would you like to donate?"));
// Set the product price to the donation amount.
product.price = donationAmount;
}
// Add the script to the product page.
addDonationPrice();
This script will prompt the customer to enter a donation amount. The donation amount will then be used to set the price of the product.
Liquid code
Another way to make a product that is dynamic in pricing is to use Liquid code. This code will allow you to dynamically set the price of the product based on the cart total.
Here is an example of Liquid code that you can use to dynamically set the price of a product:
{% if cart_total > 100 %}
// Add an additional 1% cost to the cart total.
product.price = product.price * 1.01;
{% endif %}
This code will add an additional 1% cost to the cart total if the cart total is greater than $100.
Apps
There are also a number of Shopify apps that can help you make a product that is dynamic in pricing. These apps typically have a user interface that allows you to set dynamic pricing rules.
Here are a few Shopify apps that can help you with this:
- Dynamic Pricing by Bold Commerce: This app allows you to set dynamic pricing rules based on a variety of factors, including the customer’s location, the product’s category, and the cart total.
- Price Rules by Liquid Code: This app allows you to set dynamic pricing rules based on a variety of factors, including the customer’s location, the product’s category, and the time of day.
- Dynamic Pricing Plus by Intuitive Labs: This app is a more advanced dynamic pricing app that allows you to set dynamic pricing rules based on a variety of factors, including the customer’s past purchase history, the product’s popularity, and the competition’s prices.