Jump to content

[SOLVED] Adding A Field In The PayPal Module


Recommended Posts

Hi,

Hope someone can help with this?

I'm trying to add a field or setting in Prestashop that will show up in PayPal

Ideally I'd like the reference field in the product page to appear in the PayPal statement

Currently I can only get Prestashop to update the product name, price and quantity in PayPal

All the current options in PayPal - Option 1,2, 3 and Item ID show up blank

Is there a way of updating the redirect.tpl file in the PayPal module to get it to send this info to PayPal?

I just need to be able to add a reference or stock number as a seperate field to PayPal

I've tried updating all the existing fields - reference:, EAN13, Supplier Ref:, Location: - but none of these fields are sent to PayPal

Am I missing something obvious or is it simply something Prestashop can't do?

Hope someone can help?

Best wishes

Brian

Link to comment
Share on other sites

Try this:

            <input type="hidden" name="item_number_{$k+1}" value="{$product.reference}" />



after:

 
           <input type="hidden" name="item_name_{$k+1}" value="{$product.name|escape:'htmlall':'UTF-8'}{if isset($product.attributes)} - {$product.attributes|escape:'htmlall':'UTF-8'}{/if}" />

Link to comment
Share on other sites

Hi Zenith,

Thanks for the reply!

I've inserted the code in to the redirect.tpl file (PayPal Module)

I'm quite new to this, I'm assuming the top part of code needed to go in to
the document just below this line of code (my code was slightly different to yours?)

<input type="hidden" name="item_name_{$k+1}" value="{$product.name}{if isset($product.attributes)} - {$product.attributes}{/if}" />

<input type="hidden" name="item_number_{$k+1}" value="{$product.reference}" /> <--Popped the line of code here?
<input type="hidden" name="amount_{$k+1}" value="{$product.price_wt}" />
<input type="hidden" name="quantity_{$k+1}" value="{$product.cart_quantity}" />

Hope I've got the code correct and in the right place?

I've tested it in PayPal, charge went through okay, but I don't see the reference code anywhere in the PayPal order?

I've also checked the .csv file from PayPal and it's not showing there either...

Assuming I've not been a muppet and put the code in wrong (there's a very good chance I have!), is there a way of using the reference code and telling PayPal it's something else like - 'custom' or 'os0' or another option field that PayPal recognises?

Hope that all makes sense?

Thanks again for your help

Brian

Link to comment
Share on other sites

  • 10 months later...

Thanks for the suggestion in the above posts, I'm using PayPal Module 2.6 which seems to have resolved the rounding problem, but had to add additional code to two further files.

I added the code above the the .tpl file, but found in order to get the checkout summary page to display the Item Reference Number (Product Number) I had to add the following code to the paypal.php file in the payment directory.

On the next line after Line 79 (Opened in Dreamweaver)

$request .= '&L;_NAME'.$i.'='.substr(urlencode($products[$i]['name'].(isset($products[$i]['attributes'])?' - '.$products[$i]['attributes']:'').(isset($products[$i]['instructions'])?' - '.$products[$i]['instructions']:'') ), 0, 127);



Add:-

$request .= '&L;_NUMBER'.$i.'='.urlencode($products[$i]['reference']);



Additionally in order for the Reference Numbers to be diplayed on the details (transaction page) in PayPal I had to add the same line of code to the paypal.php file in the paypal module directory.

On the next line after line after line 418 (Opened in Dreamweaver)

$request .= '&L;_NAME'.$i.'='.substr(urlencode($products[$i]['name'].(isset($products[$i]['attributes'])?' - '.$products[$i]['attributes']:'').(isset($products[$i]['instructions'])?' - '.$products[$i]['instructions']:'') ), 0, 127);



Add:-

$request .= '&L;_NUMBER'.$i.'='.urlencode($products[$i]['reference'])



This seemed to do the trick and now the product Reference is showing in both the summary page (buyer) and the payment details pages (buyer + seller).

I have tested this in sandbox and I'm using this in production and so far everything seems to be working ok.

I hope this helps someone as I spent some time searching for a solution and after finding this post it led me in the right direction (Thanks Zenith).

Link to comment
Share on other sites

×
×
  • Create New...