Perch Shop: Displaying ex VAT & inc VAT on Product Listing

  • Hi All


    I'm currently building a full online shop for trade customers only, so it shows all prices as ex VAT but I also wish to include the inc VAT price too for those not VAT registered.


    I've got it to work perfectly on a single product page but am having problems displaying it on a product list page, this is what I've got so far to display the product listing...



    ...this is basically listing all the ex VAT prices for all products in one string... £6.255.757.506.256.257.506.255.655.9997.993.4946.997.958.35 inc VAT.


    Any help to get this to work out the inc VAT price for each product individually would be much appreciated.


    Glen

  • Did not try it, but can you try using:


    Code
    1. $item['incVAT'] = perch_shop_product($item['slug'], [
    2.     'template' => 'products/ex_vat.html',
    3.     $VAT = '1.20',
    4.     $incVAT = number_format($exVAT * $VAT, 2),
    5. ], true);

    So you would use the perch_shop_product function to get a single product (using the slug) in the each-loop, instead of getting ALL the products.

  • What does your list-category.html template looks like?


  • Wait, your each function is not formatted correctly I think.



    Again doing this from the top of my head, sorry.

  • Thank you so much Mxkert for your help so far, we're getting there.


    I am now getting just one amount but I'm getting the same amount on each product listed... £6.79 inc VAT.


  • If you change $exVAT to $item['exVAT'] everywhere?

    I get the same result unfortunately...


    Code
    1. 'each' => function($item) {
    2. $item['exVAT'] = perch_shop_product($item['slug'], [
    3. 'template' => 'products/ex_vat.html'
    4. ], true);
    5. $VAT = '1.20';
    6. $item['incVAT'] = number_format($item['exVAT'] * $VAT, 2);
    7. return $item;
    8. },
  • What does your ex_vat.html look like?

    And what do you see on the page when you use the following:


  • And what do you see on the page when you use the following:




    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79



    5.656.255.757.506.256.257.506.255.9997.993.4946.997.958.35

    6.79

  • Sorry Glen, I forgot about this thread.


    What happens if you change it to

    Code
    1. $item['exVAT'] = perch_shop_product('', [
    2. 'template' => 'products/ex_vat.html',
    3. 'filter' => 'slug',
    4. 'match' => 'eq',
    5. 'value' => $item['slug'],
    6. ], true);
  • Hi Mxkert


    Thank you for your help.


    So sorry for the delay, I have had to spend more time on other projects.


    Sorry Glen, I forgot about this thread.


    What happens if you change it to

    Code
    1. $item['exVAT'] = perch_shop_product('', [
    2. 'template' => 'products/ex_vat.html',
    3. 'filter' => 'slug',
    4. 'match' => 'eq',
    5. 'value' => $item['slug'],
    6. ], true);


    ...unfortunately, no data is displayed / passed to the template.


    Glen