Post by luisvillacrez » 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:

Code: Select all

<p class="affirm-as-low-as" data-page-type="product" data-amount="<?php echo $price; ?>"></p>
and the price was showing the following: data-amount="$479.00"

cart page:

Code: Select all

<p class="affirm-as-low-as" data-page-type="cart" data-amount="<?php echo $total; ?>"></p>
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.

Code: Select all

<p class="affirm-as-low-as" data-page-type="product" data-amount="<?php echo $res = preg_replace('/[^0-9.]/', '', $price); ?>"></p>
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.

Newbie

Posts

Joined
Sun Sep 21, 2014 8:55 am

Post by Johnathan » Thu Sep 12, 2019 10:29 pm

Hi Luis, sorry I didn't get back to you yesterday, I'd already left my office. To get an integer you'd just need to multiply by 100, like this:

Code: Select all

<p class="affirm-as-low-as" data-page-type="product" data-amount="<?php echo (int)(100 * preg_replace('/[^0-9.]/', '', $price)); ?>"></p>

The $res in there also wasn't supposed to be in the code I sent you, I was working too fast! Anyway, hope this helps, if not send me a message.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am

Who is online

Users browsing this forum: No registered users and 21 guests