Ejemplo n.º 1
0
 function getCheckout($cart, $paypal, $is_sandbox, $fields = NULL)
 {
     $item_arr = array();
     $item_total = 0;
     $i = 1;
     $weight_total = 0;
     foreach ($cart['items'] as $item) {
         if ($item['quantity']) {
             $item_arr["item_name_{$i}"] = $this->getItemTitle($item, FALSE, array(), NULL);
             $item_arr["amount_{$i}"] = $item['price'];
             $item_arr["quantity_{$i}"] = $item['quantity'];
             $weight_total += $item['weight'];
             $i++;
         }
     }
     $item_arr['weight_total'] = $weight_total;
     $total = $item_total;
     $shipping_fee = 0;
     if ($cart['shipping']) {
         $shipping_fee = $cart['shipping'];
     }
     $item_arr['shipping_1'] = $shipping_fee;
     $sandbox = '';
     if ($is_sandbox) {
         $sandbox = 'sandbox.';
     }
     $inputs = '';
     if (isset($fields)) {
         $shipping_fields = '';
         $proc = new Form_Processor();
         foreach ($fields as $field) {
             $shipping_fields .= $proc->htmlRenderField($field);
         }
         $shipping_form = $this->xmlDiv($this->xmlTag('h4', 'Enter shipping information:') . $this->xmlTag('ul', $shipping_fields), array('class' => 'shopping-cart-shipping-form'));
         $inputs .= $shipping_form;
     }
     $inputs .= $this->xmlInputsHidden(array('cmd' => '_cart', 'upload' => '1', 'custom' => $cart['code']) + $paypal + $item_arr);
     $inputs .= $this->xmlEmptyTag('input', array('type' => 'image', 'src' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif'));
     $checkout_form = $this->xmlTag('form', $inputs, array('action' => "https://www.{$sandbox}paypal.com/cgi-bin/webscr", 'method' => 'post', 'novalidate' => 'novalidate'));
     $checkout = $this->xmlDiv($this->xmlTag('h3', 'Checkout') . $checkout_form, array('class' => 'shopping-cart-checkout'));
     return $checkout;
 }