// Context part 27

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7812 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2011-07-29 14:29:57 +00:00
parent 35748d1b8f
commit 5d090a25b3
66 changed files with 532 additions and 813 deletions
+14 -20
View File
@@ -74,8 +74,6 @@ class GCheckout extends PaymentModule
public function getContent()
{
global $cookie;
if (Tools::isSubmit('submitGoogleCheckout'))
{
$errors = array();
@@ -177,9 +175,7 @@ class GCheckout extends PaymentModule
if (!$this->active)
return;
global $smarty;
$smarty->assign('buttonText', $this->l('Pay with GoogleCheckout'));
$this->context->smarty->assign('buttonText', $this->l('Pay with GoogleCheckout'));
return $this->display(__FILE__, 'payment.tpl');
}
@@ -192,19 +188,17 @@ class GCheckout extends PaymentModule
public function preparePayment()
{
global $smarty, $cart, $cookie;
require_once(dirname(__FILE__).'/library/googlecart.php');
require_once(dirname(__FILE__).'/library/googleitem.php');
require_once(dirname(__FILE__).'/library/googleshipping.php');
$currency = $this->getCurrency((int)$cart->id_currency);
$currency = $this->getCurrency($this->context->cart->id_currency);
if ($cart->id_currency != $currency->id)
if ($this->context->cart->id_currency != $currency->id)
{
$cart->id_currency = (int)$currency->id;
$cookie->id_currency = (int)$cart->id_currency;
$cart->update();
$this->context->cart->id_currency = (int)$currency->id;
$this->context->cookie->id_currency = (int)$this->context->cart->id_currency;
$this->context->cart->update();
Tools::redirect('modules/'.$this->name.'/payment.php');
}
@@ -213,34 +207,34 @@ class GCheckout extends PaymentModule
Configuration::get('GCHECKOUT_MERCHANT_KEY'),
Configuration::get('GCHECKOUT_MODE'), $currency->iso_code);
foreach ($cart->getProducts() AS $product)
foreach ($this->context->cart->getProducts() AS $product)
$googleCart->AddItem(new GoogleItem(utf8_decode($product['name'].
((isset($product['attributes']) AND !empty($product['attributes'])) ?
' - '.$product['attributes'] : '')), utf8_decode($product['description_short']),
(int)$product['cart_quantity'], $product['price_wt'],
strtoupper(Configuration::get('PS_WEIGHT_UNIT')), (float)$product['weight']));
if ($wrapping = $cart->getOrderTotal(true, Cart::ONLY_WRAPPING))
if ($wrapping = $this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING))
$googleCart->AddItem(new GoogleItem(utf8_decode($this->l('Wrapping')), '', 1, $wrapping));
foreach ($cart->getDiscounts() AS $voucher)
foreach ($this->context->cart->getDiscounts() AS $voucher)
$googleCart->AddItem(new GoogleItem(utf8_decode($voucher['name']),
utf8_decode($voucher['description']), 1, '-'.$voucher['value_real']));
if (!Configuration::get('GCHECKOUT_NO_SHIPPING'))
{
$carrier = new Carrier((int)($cart->id_carrier), (int)($cookie->id_lang));
$carrier = new Carrier((int)($this->context->cart->id_carrier), $this->context->language->id);
$googleCart->AddShipping(new GoogleFlatRateShipping(utf8_decode($carrier->name),
$cart->getOrderShippingCost($cart->id_carrier)));
$this->context->cart->getOrderShippingCost($this->context->cart->id_carrier)));
}
$googleCart->SetEditCartUrl(Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'order.php');
$googleCart->SetContinueShoppingUrl(Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'order-confirmation.php');
$googleCart->SetRequestBuyerPhone(false);
$googleCart->SetMerchantPrivateData($cart->id.'|'.$cart->secure_key);
$googleCart->SetMerchantPrivateData($this->context->cart->id.'|'.$this->context->cart->secure_key);
$total = $cart->getOrderTotal();
$total = $this->context->cart->getOrderTotal();
$smarty->assign(array(
$this->context->smarty->assign(array(
'googleCheckoutExtraForm' => $googleCart->CheckoutButtonCode($this->l('Pay with GoogleCheckout'), 'LARGE'),
'total' => $total,
'googleTotal' => $total));