Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-06-25 02:50:54

zenman
Member
Registered: 2017-08-28
Posts: 38
Website

Order form: Number instead of price through plugin or variables?

Hello TXP users!

I am trying to integrate a payment system form into a TXP site. I have INPUT field that displays a product price:

<input name="sum"  value="<txp:custom_field name="Price" />" type="number"  placeholder="<txp:custom_field name="Price" />" required  step="<txp:custom_field name="Price" />" min="<txp:custom_field name="Price" />" max=""  />

If a product price = 100, it will add + 100, +100 when clicking arrows of the field (type “number”). When clicking the button BUY, it calculates TOTAL amount that user has to pay via payment gate.

Is it possible to make this field to display a number of items and price only on the payment gate?

I understand that it should be presented somehow like this <txp:custom_field name=“Price” /> = 1, may be like this <txp:variable name=“1” value=’<txp:custom_field name=“Price” />’ />… Is it possible to accomplish the task with TXP tags?

Thanks!

Offline

#2 2020-06-25 06:34:37

etc
Developer
Registered: 2010-11-11
Posts: 3,686
Website

Re: Order form: Number instead of price through plugin or variables?

I guess you could name your inputs as product items (say, apple) storing their price in corresponding cf:

<input name="apple"  value="0" type="number" min="0" />
<input name="apple_price" value='<txp:custom_field name="apple" />' type="hidden" />

and then calculate the total amount on the payment gate:

Total: <txp:evaluate query='<txp:page_url type="apple" escape="integer" /> * <txp:page_url type="apple_price" escape="float" /> + other products' />

Offline

#3 2020-06-28 17:19:43

zenman
Member
Registered: 2017-08-28
Posts: 38
Website

Re: Order form: Number instead of price through plugin or variables?

etc wrote #323996:

I guess you could name your inputs as product items (say, apple) storing their price in corresponding cf:

<input name="apple" value="0" type="number" min="0" />...

and then calculate the total amount on the payment gate:

Total: <txp:evaluate query='<txp:page_url type="apple" escape="integer" /> * <txp:page_url type="apple_price" escape="float" /> + other products' />...

Thanks. Oh, I see txp:evaluate for the first time!

It is Yandex.Kassa and they have a fixed set of names for inputs. I can’t invent my own. So the input name=“sum” is what stores the price. They also have <input type=“number” name=“orderDetails” /> for different info like name or quantity.

So far I don’t know how to connect them. May be “sum” will be “apple” and “orderDetails” will be apple_price from your example?

I accomplished it with select & adi_calc (!!!), it is close but not exactly what I planned, needless to say.

<select name="sum" value='<txp:custom_field name="Price" />'>
<option value='<txp:custom_field name="Price" />'>1</option>
<option value='<txp:adi_calc name="qq" value='<txp:custom_field name="Price" />'  multiply="2" display="1" />'>2</option>
<option value='<txp:adi_calc name="qq" value='<txp:custom_field name="Price" />'  multiply="3" display="1" />'>3</option>
</select>

Offline

#4 2020-06-29 10:05:01

etc
Developer
Registered: 2010-11-11
Posts: 3,686
Website

Re: Order form: Number instead of price through plugin or variables?

Ah. If you control only the input form, then you can alter the value of sum on submit via JS, multiplying it by Price.

Offline

Board footer

Powered by FluxBB