Pulse Script ex-vat and 3 decimal places

Open to all! Ask other shopowners for help.
cbs
50+
Posts: 64
Joined: Tue Oct 26, 2021 9:42 am
Phoenix Version: v1.1.0.7
Has thanked: 9 times
Been thanked: 10 times

Pulse Script ex-vat and 3 decimal places

Post by cbs »

Why does our pulse script code show the prices ex-vat and with 3 decimal places?

Code: Select all

<script>
  window.pulse = window.pulse || [];
</script>
<script>
  window.pulse = window.pulse || [];
  window.pulse.push({
    event: 'product_view',
    payload: {
      product_name: "product_name",
      sku: "sku",
      price: 29.158,
      currency: "GBP",
      product_id: product_id
    },
    page_url: window.location.href,
    referrer: document.referrer,
    domain: window.location.hostname,
    timestamp: new Date().toISOString()
  });
</script>



Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: Pulse Script ex-vat and 3 decimal places

Post by burt »

That's the price of that particular product, right? Check it out (in your admin product editing/adding page, or direct in the DB).

I'd be more worried about `product_name: "product_name",` but I'm guessing you changed this for privacy?
I am not here to build for you.
I am here to build with you. Let's help each other.

cbs
50+
Posts: 64
Joined: Tue Oct 26, 2021 9:42 am
Phoenix Version: v1.1.0.7
Has thanked: 9 times
Been thanked: 10 times

Re: Pulse Script ex-vat and 3 decimal places

Post by cbs »

Sorry, yea I've removed the product name, SKU and product id. They are all correct.

That's price without VAT but it really should be with VAT.

cbs
50+
Posts: 64
Joined: Tue Oct 26, 2021 9:42 am
Phoenix Version: v1.1.0.7
Has thanked: 9 times
Been thanked: 10 times

Re: Pulse Script ex-vat and 3 decimal places

Post by cbs »

Looked in the database and 29.158 is the price there, would I need to edit the pulse file to add VAT or is there another way of doing it?

User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: Pulse Script ex-vat and 3 decimal places

Post by burt »

I'm probably missing something obvious here, apologies if so...

What/where is the price used, and why would having it incl tax make a difference ?

It's only stored in the `payload` blob, right?
I am not here to build for you.
I am here to build with you. Let's help each other.

cbs
50+
Posts: 64
Joined: Tue Oct 26, 2021 9:42 am
Phoenix Version: v1.1.0.7
Has thanked: 9 times
Been thanked: 10 times

Re: Pulse Script ex-vat and 3 decimal places

Post by cbs »

I have no clue what pulse is or what it's used for but it's on every product page.

It just seems like having all the prices in the code on the page matching using the same format would be best practice.

User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: Pulse Script ex-vat and 3 decimal places

Post by burt »

Inbuilt Analytics, see report page in your admin area (I don't recall which menu), maybe "reports".
I am not here to build for you.
I am here to build with you. Let's help each other.

User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: Pulse Script ex-vat and 3 decimal places

Post by burt »

@cbs
After you've had a look to see what Pulse is, post back if you still need prices with VAT.
It'll be a hook override and fairly straightforward, I think.
I am not here to build for you.
I am here to build with you. Let's help each other.

cbs
50+
Posts: 64
Joined: Tue Oct 26, 2021 9:42 am
Phoenix Version: v1.1.0.7
Has thanked: 9 times
Been thanked: 10 times

Re: Pulse Script ex-vat and 3 decimal places

Post by cbs »

If its only used for internal analytics and doesn't affect anything else, I'll just leave it.

Thank you

User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: Pulse Script ex-vat and 3 decimal places

Post by burt »

Others may want same in the future, so I think if you do this, it may work.

1. copy/override file

From:
/includes/hooks/shop/product_info/pulseCart.php

To:
/templates/your_selected_template/includes/hooks/shop/product_info/pulseCart.php

IE, if you use "override" template change your_selected_template to override.

2. change that new file you just made

Find this:
$price = (float)$product->get('final_price');

Change to:
$price = (float)$product->format_raw();

And save it, then check your product page to see if it shows the incl VAT price.
If you do try this, please let me know if it worked OK or no.
I am not here to build for you.
I am here to build with you. Let's help each other.



Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply