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: 41
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: 5,028
Website GitHub

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: 41
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: 5,028
Website GitHub

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

#5 2020-07-02 23:25:29

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

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

etc wrote #324085:

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

seems to me this is not enough. it takes the variable data but does not pass it to the payment gate.

<script>
function multi(){
var q = document.getElementById('sum').value;
return (q * <txp:custom_field name="sum" />);
}
</script>
<form action="https://money.yandex.ru/eshop.xml" method="post" onsubmit="multi()">

Is it possible to make txp:variable name=“q” value=“document.getElementById(‘sum’).value” />?

Offline

#6 2020-07-03 06:14:10

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

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

zenman wrote #324218:

seems to me this is not enough. it takes the variable data but does not pass it to the payment gate.

Have you tried to alter the value of sum input itself?

<script>
function multi(){
    var sum = document.getElementById('sum'), q = sum.value;
    sum.value = q * <txp:custom_field name="sum" escape="float" />;

    return true;
}
</script>

<form action="https://money.yandex.ru/eshop.xml" method="post" onsubmit="multi()">

Offline

#7 2020-07-03 20:04:12

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

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

etc wrote #324222:

Have you tried to alter the value of sum input itself?

<script>...

Oh, Thank you very much! It works! On click a number in the field turns into a sum, and it passes to the payment gate. I think it is enough for this payment widget.

Yandex.Kassa has its plugins for WP, Joomla, OpneCart e-commerce. As for TXP, one has to play with this E-mail widget.

Offline

Board footer

Powered by FluxBB