Affirm echo $price and $total in USD cents (e.g., $100 = 10000)
Posted: Thu Sep 12, 2019 6:20 am
Hello,
Im having some issues rendering the right promotional message.
Currently, in the product page and cart page it renders a generic message.
' Buy in monthly payments with Affirm on orders over $50. Learn more '
For the coding i have the following:
product page:
and the price was showing the following: data-amount="$479.00"
cart page:
However, they told me this ' It looks like the data amount that's being passed to calculate the messaging is being passed as a string rather than an integer. If a valid number is passed, the monthly messaging you've requested should show up! '
In their docs they have the following for the data amount:
Be sure to use your page's price variable or price amount in USD cents (e.g., $100 = 10000) for data-amount.
I have checked other site using Affirm and they have it this way: price $749.99 | data-amount="74999"
Later, i changed the code to this with the help of someone.
and now the price shows as $479 | data-amount="479.00"
What code for the product page $price and cart page total $total would i need to render the number as an integer as affirm requires it?
Thank you in advanced.
Im having some issues rendering the right promotional message.
Currently, in the product page and cart page it renders a generic message.
' Buy in monthly payments with Affirm on orders over $50. Learn more '
For the coding i have the following:
product page:
Code: Select all
<p class="affirm-as-low-as" data-page-type="product" data-amount="<?php echo $price; ?>"></p>
cart page:
Code: Select all
<p class="affirm-as-low-as" data-page-type="cart" data-amount="<?php echo $total; ?>"></p>
In their docs they have the following for the data amount:
Be sure to use your page's price variable or price amount in USD cents (e.g., $100 = 10000) for data-amount.
I have checked other site using Affirm and they have it this way: price $749.99 | data-amount="74999"
Later, i changed the code to this with the help of someone.
Code: Select all
<p class="affirm-as-low-as" data-page-type="product" data-amount="<?php echo $res = preg_replace('/[^0-9.]/', '', $price); ?>"></p>
What code for the product page $price and cart page total $total would i need to render the number as an integer as affirm requires it?
Thank you in advanced.