Essentially what I want to do is take advantage of paypals shopping cart variables. Currently open cart only sends a lump sum to paypal, but paypal has features that enable a page to send items to the paypal cart. These features would allow a user to have a better confirmation of their order so that they know exactly what they are paying for. These variables can easily be sent to paypal through hidden inputs. Go to https://www.paypal.com/IntegrationCente ... pload.html to see how all this works. I'll give an example below.
This would be an example cart sending multiple items to paypal's checkout:
Code: Select all
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">//<----------------------------------------important change
<input type="hidden" name="upload" value="1">//<------------------------------------------important change
<input type="hidden" name="business" value="seller@designerfotos.com">
<input type="hidden" name="item_name_1" value="Item Name 1">
<input type="hidden" name="item_number_1" value="Product Model 1">
<input type="hidden" name="amount_1" value="1.00">
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="item_name_2" value="Item Name 2">
<input type="hidden" name="item_number_2" value="Product Model 1">
<input type="hidden" name="amount_2" value="2.00">
<input type="hidden" name="quantity_2" value="3">
<input type="submit" value="PayPal">
</form>
So my terrible coding has got me editing the checkout_confirmation.tpl to allow for this. But I need to add shipping too. Any geniuses out there that could maybe configure the paypal.php extension to modify it for a shopping cart?
My current code just for ideas... You'll see that I've also taken advantage of the customization of paypal to integrate it into the opencart's design theme:
paypal.php
Code: Select all
$ouput = '<input type="hidden" name="cmd" value="_cart" />' . "\n";
$ouput .= '<input name="upload" type="hidden" value="1" />' . "\n";
$ouput .= '<input type="hidden" name="business" value="' . $this->config->get('paypal_email') . '" />' . "\n";
$ouput .= '<input type="hidden" name="currency_code" value="' . $currency . '" />' . "\n";
$ouput .= '<input type="hidden" name="first_name" value="' . $this->order->get('firstname') . '" />' . "\n";
$ouput .= '<input type="hidden" name="last_name" value="' . $this->order->get('lastname') . '" />' . "\n";
$ouput .= '<input type="hidden" name="address1" value="' . $this->order->get('payment_address_1') . '" />' . "\n";
$ouput .= '<input type="hidden" name="address2" value="' . $this->order->get('payment_address_2') . '" />' . "\n";
$ouput .= '<input type="hidden" name="city" value="' . $this->order->get('payment_city') . '" />' . "\n";
$ouput .= '<input type="hidden" name="zip" value="' . $this->order->get('payment_postcode') . '" />' . "\n";
$ouput .= '<input type="hidden" name="country" value="' . $this->order->get('payment_country') . '" />' . "\n";
$ouput .= '<input type="hidden" name="address_override" value="0" />' . "\n";
$ouput .= '<input type="hidden" name="notify_url" value="' . $this->url->ssl('checkout_process', 'callback', array('payment' => 'paypal')) . '" />' . "\n";
$ouput .= '<input type="hidden" name="email" value="' . $this->order->get('email') . '" />' . "\n";
$ouput .= '<input type="hidden" name="invoice" value="' . $this->order->getReference() . '" />' . "\n";
$ouput .= '<input type="hidden" name="lc" value="' . $this->language->getCode() . '" />' . "\n";
$ouput .= '<input type="hidden" name="return" value="' . $this->url->ssl('checkout_process') . '" />' . "\n";
$ouput .= '<input type="hidden" name="rm" value="2" />' . "\n";
$ouput .= '<input type="hidden" name="no_note" value="1" />' . "\n";
$ouput .= '<input type="hidden" name="cancel_return" value="' . $this->url->ssl('checkout_payment') . '" />' . "\n";
$ouput .= '<input type="hidden" name="paymentaction" value="authorization" />' . "\n";
Code: Select all
<form action="<?php echo $payment_url; ?>" name="_xclick" method="post" enctype="multipart/form-data">
<?php if ($fields) { ?>
<div class="a"><?php echo $fields; ?>
<?php foreach ($products as $key => $product) {
$product['key'] = $key + 1;
echo '<input type="hidden" name="item_name_' . $product['key'] . '" value="' . $product['name'] . '" />' . "\n";
echo '<input type="hidden" name="item_number_' . $product['key'] . '" value="' . $product['model'] . '" />' . "\n";
echo '<input type="hidden" name="amount_' . $product['key'] . '" value="' . $product['price'] . '" />' . "\n";
echo '<input type="hidden" name="quantity_' . $product['key'] . '" value="' . $product['quantity'] . '" />' . "\n";
}?>
<input name="cpp_header_image" type="hidden" value="http://www.solidrockunltd.com/catalog/template/default/image/paypal-header.jpg" />
<input name="cpp_payflow_color" type="hidden" value="#cbe2f1" />
<input name="cpp_headerborder_color" type="hidden" value="#cbe2f1" />
</div>
<?php } ?>
<?php if (isset($agree)) { ?>
<div class="buttons">
<table>
<tr>
<td align="left"><input type="button" value="<?php echo $button_back; ?>" onclick="location='<?php echo $back; ?>'" /></td>
<td align="right"><?php echo $agree; ?></td>
<td align="right" width="5"><input type="checkbox" name="agreed" value="1" onclick="document.getElementById('submit').disabled = (this.checked == true) ? false : true;" /></td>
<td align="right" width="5"><input type="submit" value="<?php echo $button_continue; ?>" id="submit" disabled /></td>
</tr>
</table>
</div>
<?php } else { ?>
<div class="buttons">
<table>
<tr>
<td align="left"><input type="button" value="<?php echo $button_back; ?>" onclick="location='<?php echo $back; ?>'" /></td>
<td align="right"><input type="submit" value="<?php echo $button_continue; ?>" /></td>
</tr>
</table>
</div>
<?php } ?>
</form>