Forums

Paypal multiple value

cornelio 08 Mar, 2017
Hi,
I need to put on an array the ids of products that come from the cart and then to call array and associate it [item_name] paypal.
example: [item_name] = 2,3,4,5, ...
or how to add more products into paypal variables
Thanks a lot

Cornelio
Max_admin 09 Mar, 2017
Hi Cornelio,

In the PayPal redirect action the "item_name" field accepts an array, you may also turn the debug setting in the PayPal action to check how the data provided is passed to PayPal.

From the PayPal redirect action:

The field name holding the item's title, if the field value is an array then multiple items will be shown on the PayPal page, and both the amount and quantity fields should be of type array too. also for this to work, the Command should be set to '_cart' and you should add upload="1" to the extra params box.



Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cornelio 09 Mar, 2017
Hi Max,

many thanks for the quick answer Max.
I will try with your suggestion.

what I get is this:


<p><b>Results:</b> <span id="results"></span></p>
<form>
 
  <div><input type="text" name="a" value="21" id="a"></div>
  <div><input type="text" name="b" value="22" id="b"></div>
  <div><input type="text" name="c" value="34" id="c"></div>
  <div>
</form>
 

function showValues() {
    var fields = $( ":input" ).serializeArray();
    $( "#results" ).empty();
    jQuery.each( fields, function( i, field ) {
      $( "#results" ).append( field.value + " " );
    });
  }
 
  $( ":input" ).focus( showValues );
  
  showValues();


Results: 21 22 34

cornelio 09 Mar, 2017
Hi Max,
i tryed with your suggestion and not any array as a result see attachments.

Best Regard
Cornelio
GreyHead 09 Mar, 2017
Hi Cornelio,

I can't work out what your code examples are supposed to do. The PHP one has <form> tags with no action URL so that will do nothing useful.

You need to make the Item name field, Amount field and Quantity inputs from your form all into arrays e.g. name=foto[], name=price[] name=qty[] and you need to validate that all three values are completed for each item.

You can them put these names in the PayPal redirect action - without the []

Note that you have a typo in the notify_url entry and the upload entry is missing the quotes - it should be upload="1"

Bob
cornelio 09 Mar, 2017
Hi Bob,
thanks for the quick answer.

the posted code was just an example of how to get the result.

certainly you can do in different ways.
my IPN page:
in ipn page, I would like to have the possibility of downloading digital files, filtered by ids, after payment
example:
//*$form-> data ['item_name'] // in where sql condition


$form->data['id_foto'] = $form->data['item_name'];

$db =JFactory::getDBO(); 
$i=0;
$session =JFactory::getSession();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('cf_id','p_description', 'allegato')));
$query->from($db->quoteName('#__cf_product_data-2'));
$query->where($db->quoteName('cf_id') . " = '". $form->data['id_foto']."'"); //id= id_foto  plugin paypal
//$query->order('ordering ASC');


Note that you have a typo in the notify_url entry and the upload entry is missing the quotes - it should be upload="1"


upload="1" or upload=1 -> I tried but nothing


Best Regards
Cornelio
Max_admin 09 Mar, 2017
Hi Cornelio,

You have "id_foto" in the "item_name" field, this field must supply an array of values if you want to send multiple values to PayPal, the way to do this is to change the field name to "id_foto[]", the same must be done with the amount and quantity fields.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cornelio 09 Mar, 2017
Thanks Max, but this is the first thing I tried, but without success.
if it puts [] not me carrying values of item_name paypal

Regards
Cornelio
cornelio 09 Mar, 2017
Hi,

this example code if it helps to understand what I want.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>serializeArray demo</title>
  <style>
  body, select {
    font-size: 14px;
  }
  form {
    margin: 5px;
  }
  p {
    color: red;
    margin: 5px;
  }
  b {
    color: blue;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
 
<p><b>(Onchange)= results formatted to associate with [item_name] of paypal:</b> <span id="results"></span></p>
<form>
  <div><input type="text" name="a" value="1" id="a"></div>
  <div><input type="text" name="b" value="2" id="b"></div>
  <div><input type="text" name="c" value="3" id="c"></div>
  <div><input type="text" name="d" value="4" id="d"></div>
     
</form>
 
<script>
  function showValues() {
    var fields = $( ":input" ).serializeArray();
    $( "#results" ).empty();
    jQuery.each( fields, function( i, field ) {
      $( "#results" ).append( field.value + "," );
    });
  }
  
  $( "input" ).change( showValues );
    showValues();
</script>
 
</body>
</html>


the link where it is running: test

thanks for your patience

Cornelio
Max_admin 10 Mar, 2017
Hi Cornelio,

The PayPal settings has "id_foto" in the "item_name" field, and so the fields named should be "id_foto[]", but you have a, b, c...ect, this will not work of course.

The JavaScript code for serializing data is also not helpful here and is not needed.

You need a field like this:
<input type="text" name="id_foto[]" value="1" />


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.