function listItemPreprocess() { debug($this->settings); $this->set('blob', $this->getBlob()); $this->set('devMode', !empty($this->settings['devMode'])); parent::listItemPreprocess(); }
function listItemPreprocess() { //debug($this->settings); //$this->set('blob',$this->getBlob()); if (empty($this->controller->helpers['PaypalIpn.Paypal'])) { $this->controller->helpers['PaypalIpn.Paypal'] = array('business' => $this->settings['business'], 'currency_code' => strtoupper(!empty($this->payment['ShopPayment']['currency']) ? $this->payment['ShopPayment']['currency'] : Configure::read('Shop.currency'))); if (!empty($this->settings['devMode'])) { $this->controller->helpers['PaypalIpn.Paypal']['test'] = true; } } $this->set('devMode', !empty($this->settings['devMode'])); //debug($this->payment); $buttonData = array('type' => 'cart', 'return' => array('plugin' => 'shop', 'controller' => 'shop_payments', 'action' => 'finish', $this->payment['ShopPayment']['id'], 'type' => 'paypal'), 'cancel_return' => array('plugin' => 'shop', 'controller' => 'shop_payments', 'action' => 'cancel', $this->payment['ShopPayment']['id'], 'type' => 'paypal'), 'notify_url' => array('plugin' => 'shop', 'controller' => 'shop_payments', 'action' => 'response', $this->payment['ShopPayment']['id'], 'type' => 'paypal')); $taxes = 0; $shipping = 0; $total = 0; $discount = 0; $currentShopOrderId = null; foreach ($this->payment['ShopOrder'] as $o_num => $order) { $currentShopOrderId = $order['id']; foreach ($order['ShopOrdersItem'] as $i_num => $item) { //debug($item); $buttonData['items'][] = array('item_name' => strip_tags($item['item_title']), 'amount' => round($item['final_price'], 2), 'quantity' => $item['nb'], 'item_number' => $item['product_id']); } $taxes += $order['total_taxes']; $shipping += $order['total_shipping']; $total += $order['total']; $discount += $order['discount']; if (!empty($order['billing_first_name'])) { $buttonData['email'] = $order['billing_email']; $buttonData['first_name'] = $order['billing_first_name']; $buttonData['last_name'] = $order['billing_last_name']; $buttonData['address1'] = $order['billing_address']; if (!empty($order['billing_apt'])) { $buttonData['address1'] .= '(' . $order['billing_apt'] . ')'; } $buttonData['city'] = $order['billing_city']; $buttonData['state'] = $order['billing_region']; $buttonData['country'] = $order['billing_country']; $buttonData['lc'] = $order['billing_country']; $buttonData['zip'] = $order['billing_postal_code']; $buttonData['night_phone_a'] = $order['billing_tel']; $buttonData['night_phone_b'] = $order['billing_tel2']; } } $buttonData['tax_cart'] = round($taxes, 2); $buttonData['handling_cart'] = $shipping; $buttonData['amount'] = $total; $buttonData['discount_amount_cart'] = $discount; $buttonData['charset'] = Configure::read('App.encoding'); //Change Return Path Paypal if (isset($this->settings['skipFinishStepOnReturn']) && $this->settings['skipFinishStepOnReturn'] && is_numeric($currentShopOrderId)) { $buttonData['return'] = array('plugin' => 'shop', 'controller' => 'shop_orders', 'action' => 'ordered', $currentShopOrderId, 'type' => 'paypal'); } $this->set('buttonData', $buttonData); parent::listItemPreprocess(); }