Aw: How do you display products on Paypal checkout / Front end currency selection
I am hoping you can give me some direction to help edit the core Paypal payment extension to send the product data and attributes to Paypal.
If I use a hybrid of programming to get the data and attributes like this:
function _addProductToForm($product, $product_item){
if (isset($product->product_attributes) && $product->product_attributes!=''){
$desc = trim($product->product_name."\n".$product->product_attributes);
}else{
$desc = trim($product->product_name);
}
$name = $product->product_name;
if ($this->productNameWithAttributs){
$name = $desc;
}
return '&L_PAYMENTREQUEST_0_NAME'.$product_item.'='.urlencode($name).
'&L_PAYMENTREQUEST_0_NUMBER'.$product_item.'='.urlencode($product->product_ean).
'&L_PAYMENTREQUEST_0_DESC'.$product_item.'='.urlencode($desc).
'&L_PAYMENTREQUEST_0_AMT'.$product_item.'='.round($product->product_item_price, 2).
'&L_PAYMENTREQUEST_0_QTY'.$product_item.'='.$product->product_quantity;
}
How can I then use that data to insert it into the Paypal form to submit it to Paypal like this:
<?php $items = unserialize($_SESSION['items']); ?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="business" value="email@yahoo.ca">
<input type="hidden" name="currency_code" value="CAD">
<input type="hidden" name="return" value="http://www.mysite.com/">
<?php
$suffix = 1;
foreach($items as $item):
?>
<input type="hidden" name="item_name_<?php echo $suffix; ?>" value="<?php echo $item['name']; ?>">
<?php
$suffix++;
endforeach;
?>
<input type="submit" name="paypal" id="paypal" value="Checkout" />
</form>
What I need to know is what to do to get the function to insert the product name and attributes into this script?
What should this line read:
<?php $items = unserialize($_SESSION['items']); ?>
And then what should this line read to insert them into the script:
<input type="hidden" name="item_name_<?php echo $suffix; ?>" value="<?php echo $item['name']; ?>">
Maybe collectively we can figure this out and help each other to get this solved.