Showing price after an automatic discount directly on the product page

Highlighted
Shopify Partner
1 0 8

Hi there!

 

I wanted to test the automatic discounts for special events, for example the Summer Sales or whatever.

So the I created my automatic discount and selected the products I want to apply it on. On the cart, no problem the price displayed is the actual price minus the reduction.

 

Thing is, I'd like to change the price on the product page too. For the moment, the normal price is still displayed. If possible I would like to avoid setting the price manually for each variant of each product, I have a lot of them...

 

In fact, I'd like to have something exactly like when you I apply manually the discount in the 'Pricing' section of the product: the real price crossed and the discounted price showed. And with the sentence 'You saved $XX !" also.

 

I tried to modify the code by copying the code from the cart page to the product page but was unsuccessful. I can't manage to get the discounted price, the price showing is still the one before the discount.

 

Anyone has an idea how I can solve this ? Or an indication ?

 

Thanks a lot!

Highlighted
New Member
2 0 1

This is exacly what I'm looking for and got nothing yet on google, I hope someone could help us.

Highlighted
New Member
1 0 4
I’ve been looking for this! So, far I’ve asked 3 Shopify collaborators who have been no help and told me it only exists for the cart page. I feel like this is a necessity for online shops, yet Shopify lacks that major feature. I hope someone can solve this soon.
Highlighted
New Member
1 0 1

I have the same issues, I am not able to find anything to help

Highlighted
Excursionist
35 0 42

Looking for a solution for this as well....

 

Shopify....? Are you listening?

Highlighted
Tourist
5 0 3

Same here, would love to only have 1 price list, then everything else managed by "automatic discounting"

 

Have requested via live chat, so will wait to hear back

Highlighted
New Member
2 0 5

I'm trying to do the same thing.  I had to go back to my products and change the pricing manually, and take off the automatic discount.  It was easy though with holding down shift key and clicking the bottom cell to be able to change all at once.  I agree - Shopify needs to add an option to the discount settings so that customers can see the discount reflect immediately.  

Highlighted
New Member
1 0 4

I can't believe this isn't available yet - all the major retailers have slashed prices (especially on Cyber Monday) and you are way more apt to add something to your cart when you see the savings. Shopify - please hurry up!


Highlighted
Tourist
12 1 1

After much research, I also did not find a solution on the internet. The main problem is that 'line_level_discount_allocations' is only available in a for loop which traverses the 'cart' object. I tinker with a functional solution for our shop, but I warn you I am a novice:

 

let pvfID = {{ product.variants.first.id }},
            newVal = 1,
            discounts= [],
            discountAllocation = function (type, title, value, valueType, allocationMethod, targetSelection, targetType, totalAllocatedAmount) {
              this.type = type;
              this.title = title;
              this.value = value;
              this.valueType = valueType;
              this.allocationMethod = allocationMethod;
              this.targetSelection = targetSelection;
              this.targetType = targetType;
              this.totalAllocatedAmount = totalAllocatedAmount;
            },
            pvfIDPOST = function() {
              jQuery.post('/cart/add.js', {quantity: 1, id: pvfID})
            },
            pvfIDREMOVE = function(newQty){
              jQuery.post('/cart/change.js', {quantity: newQty, id: pvfID})
            };
       
        $.when( pvfIDPOST() ).done(setTimeout (function() {        	
            jQuery.getJSON('/cart.js', function(cart) {      
              for(let i = 0; i < cart.items.length; i++){
                if(pvfID === cart.items[i].id){
                    let currentQty = cart.items[i].quantity;
                    if(cart.items[i].line_level_discount_allocations.length > 0){
                      for(let it = 0; it < cart.items[i].line_level_discount_allocations.length; it++){
                        let currentItem = cart.items[i].line_level_discount_allocations[it].discount_application;                        
                        discounts[it] = new discountAllocation(currentItem.type, currentItem.title, currentItem.value, currentItem.value_type, currentItem.allocation_method, currentItem.target_selection, currentItem.target_type, currentItem.total_allocated_amount);                                                
                      }
                      showDiscount();
                      pvfIDREMOVE(currentQty-1);
                    }else{
					  console.log('discount allocations not fount');
                      pvfIDREMOVE(currentQty-1);
                    }
                }
              }
            });
			Shopify.getCart(function(data){ console.log(data); })
        }, 2000 ));
        
        function showDiscount(){
          for(let i = 0; i < discounts.length; i++){
            
            console.log(discounts[i])
          }
        }

This javascript code uses the jquery library. it uses the shopify API to add the product from the product page consulted in the cart, extracts the automatic promotion and finally it removes the product from the cart. The content of the automatic promotion will be visible in the console. You still have to modify the current code to display the information that interests you on your template.

0 Likes
Highlighted
New Member
2 0 0

did you found already a solution?

 

thanks

 

iwan

 

0 Likes