Hello,
I want to handle two items with their corresponding prices to PayPal using PayPal Redirect.
It works fine with ONE item/amount (i.e., no array).
For two items I need to define item, (quantity) and amount as arrays. To do so I have set up:
[list] a dropdown with Field Name: item[]
2 Text fields with Field Names: amount[0] and amount[1][/list]
this also works fine, both when one or two items are selected.
My goal is: a single-select dropdown and optionally a second item to select by a checkbox. I have a checkbox named item[1] and amount[1] is a defined amount - THIS works fine.
BUT: for amount [0] that corresponds to the dropdown-selected item[0] of course I don't want to use a textfield but I want to link the options to their predifined prices/amounts.
I feel that I am close to my goal but I can't reach it😟
Could you please give me a hint how this can be handled? I tried different approaches but without success. Also the idea to set $form->data["amount[0]"] was obviously not a good one (nevertheless, it should be possible to assign such an array- value???)
Any help appreciated,
ivo
I want to handle two items with their corresponding prices to PayPal using PayPal Redirect.
It works fine with ONE item/amount (i.e., no array).
For two items I need to define item, (quantity) and amount as arrays. To do so I have set up:
[list] a dropdown with Field Name: item[]
2 Text fields with Field Names: amount[0] and amount[1][/list]
this also works fine, both when one or two items are selected.
My goal is: a single-select dropdown and optionally a second item to select by a checkbox. I have a checkbox named item[1] and amount[1] is a defined amount - THIS works fine.
BUT: for amount [0] that corresponds to the dropdown-selected item[0] of course I don't want to use a textfield but I want to link the options to their predifined prices/amounts.
I feel that I am close to my goal but I can't reach it😟
Could you please give me a hint how this can be handled? I tried different approaches but without success. Also the idea to set $form->data["amount[0]"] was obviously not a good one (nevertheless, it should be possible to assign such an array- value???)
Any help appreciated,
ivo
Hi ivo,
I don't quote follow the logic of the drop-downs + text fields + checkboxes :-( Can you give an example or two?
The structure that you want to end up with it like this
See the rest of the note under the Item Field Name box too "also for this to work, the Command should be set to '_cart' and you should add upload="1" to the extra params box."
Bob
I don't quote follow the logic of the drop-downs + text fields + checkboxes :-( Can you give an example or two?
The structure that you want to end up with it like this
$form->data['item'][0] = 'aaa';
$form->data['amount'][0] = '111';;
$form->data['quantity'][0] = '888';
$form->data['item'][1] = 'bbb';
$form->data['amount'][1] = '222'
$form->data['quantity'][1] = '999';
See the rest of the note under the Item Field Name box too "also for this to work, the Command should be set to '_cart' and you should add upload="1" to the extra params box."
Bob
Hi Bob,
sorry for the confusing details - I just wanted to stress that I did my best before posting...
So thank you very much for this: $form->data['item'] [0], I was not aware that this is the way to address the array.
With this information it works:
I have a dropdown item[0] with:
Category A= A
Category B=B
and a custom code:
if ($form->data['item'] [0] == "Category A") {
$form->data['amount'] [0] = '100';
} elseif ($form->data['item'] [0] == "Category B") {
$form->data['amount'] [0] = '200';
}
Thank you very much!!
all the best
ivo
sorry for the confusing details - I just wanted to stress that I did my best before posting...
So thank you very much for this: $form->data['item'] [0], I was not aware that this is the way to address the array.
With this information it works:
I have a dropdown item[0] with:
Category A= A
Category B=B
and a custom code:
if ($form->data['item'] [0] == "Category A") {
$form->data['amount'] [0] = '100';
} elseif ($form->data['item'] [0] == "Category B") {
$form->data['amount'] [0] = '200';
}
Thank you very much!!
all the best
ivo
This topic is locked and no more replies can be posted.