0
  1. In the store, each logged customer has own prices (depending on discounts he/she's got) for all products.
  2. Therefore all prices are being pulled via AJAX call so that Full Page Caching is still available to use.
  3. On product page it is simple as one AJAX call has to be performed to get product price.
  4. How to achieve it on category page where you can find 30-60-90 products? Each product in the list needs to perform own AJAX call.

Please advice me on this. Thanks!

0

Solved. In phtml template:

<div class="price-container price-final_price tax">
    <span data-price-type="finalPrice" class="price-wrapper ">
        <span class="price" id="price-section-<?php echo $productId ?>">
        </span>
    </span>    
</div>
<script>
require([
    'jquery',
    'XXX_YYY/js/price-collector'
], function($, priceCollector){
    priceCollector(<?php echo $productId ?>).done(
        function(response){
            $('#price-section-<?php echo $productId ?>').html(response[1]);
        }
    );    
});    
</script>

The above performs AJAX query for every product in the list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.