Пример #1
0
 /**
  * Generate PagSeguro Products
  * @return array
  */
 private function _generatePagSeguroProductsData()
 {
     $pagSeguroItens = array();
     $cont = 1;
     foreach ($this->cart->getProducts() as $product) {
         $pagSeguroItem = new PagSeguroItem();
         $pagSeguroItem->setId($cont++);
         $pagSeguroItem->setDescription($product['name']);
         $pagSeguroItem->setQuantity($product['quantity']);
         $pagSeguroItem->setAmount(str_replace("R\$", "", $this->currency->format($product['price'], $this->_order_info['currency_code'], false, false)));
         $pagSeguroItem->setWeight($product['weight'] * 1000);
         array_push($pagSeguroItens, $pagSeguroItem);
     }
     return $pagSeguroItens;
 }
 public function addItem($id, $description = null, $quantity = null, $amount = null, $weight = null, $shippingCost = null)
 {
     $param = $id;
     if ($this->items == null) {
         $this->items = array();
     }
     if (is_array($param)) {
         array_push($this->items, new PagSeguroItem($param));
     } else {
         if ($param instanceof PagSeguroItem) {
             array_push($this->items, $param);
         } else {
             $item = new PagSeguroItem();
             $item->setId($param);
             $item->setDescription($description);
             $item->setQuantity($quantity);
             $item->setAmount($amount);
             $item->setWeight($weight);
             $item->setShippingCost($shippingCost);
             array_push($this->items, $item);
         }
     }
 }
 /**
  * Get information of purchased items
  * @return PagSeguroItem
  */
 private function getItensInformation()
 {
     $Itens = $this->order->getAllVisibleItems();
     $PagSeguroItens = array();
     //CarShop Items
     foreach ($Itens as $item) {
         $PagSeguroItem = new PagSeguroItem();
         $PagSeguroItem->setId($item->getId());
         $PagSeguroItem->setDescription(self::fixStringLength($item->getName(), 255));
         $PagSeguroItem->setQuantity(self::toFloat($item->getQtyOrdered()));
         $PagSeguroItem->setWeight(round($item->getWeight()));
         $PagSeguroItem->setAmount(self::toFloat($item->getPrice()));
         array_push($PagSeguroItens, $PagSeguroItem);
     }
     return $PagSeguroItens;
 }
 /**
  * @param $data
  * @return PagSeguroItem
  */
 private static function parseTransactionItem($data)
 {
     // <transaction> <items> <item>
     $item = new PagSeguroItem();
     // <transaction> <items> <item> <id>
     if (isset($data["id"])) {
         $item->setId($data["id"]);
     }
     // <transaction> <items> <item> <description>
     if (isset($data["description"])) {
         $item->setDescription($data["description"]);
     }
     // <transaction> <items> <item> <quantity>
     if (isset($data["quantity"])) {
         $item->setQuantity($data["quantity"]);
     }
     // <transaction> <items> <item> <amount>
     if (isset($data["amount"])) {
         $item->setAmount($data["amount"]);
     }
     // <transaction> <items> <item> <weight>
     if (isset($data["weight"])) {
         $item->setWeight($data["weight"]);
     }
     return $item;
 }
Пример #5
0
 /**
  * Sets items of payment for PagSeguroLybrary
  * 
  * @param type $order
  * @return array
  */
 public function setItems($order)
 {
     global $woocommerce;
     $count = 1;
     $pagSeguroItens = array();
     foreach ($order->get_items() as $item) {
         if ($item['qty']) {
             $pagSeguroItem = new PagSeguroItem();
             foreach ($woocommerce->cart->cart_contents as $cart_item_key => $values) {
                 $_product = $values['data'];
                 if ($_product->id == $item['product_id']) {
                     $pagSeguroItem->setWeight($_product->get_weight() * 1000);
                     break;
                 }
             }
             $pagSeguroItem->setId($count);
             $pagSeguroItem->setDescription($item['name']);
             $pagSeguroItem->setQuantity($item['qty']);
             $pagSeguroItem->setAmount($order->get_item_total($item, false));
             $count++;
             array_push($pagSeguroItens, $pagSeguroItem);
         }
     }
     return $pagSeguroItens;
 }
Пример #6
0
 /**
  *  Generates products data to PagSeguro transaction
  * 
  *  @return Array PagSeguroItem
  */
 private function _generateProductsData()
 {
     $pagseguro_items = array();
     $cont = 1;
     foreach ($this->context->cart->getProducts() as $product) {
         $pagSeguro_item = new PagSeguroItem();
         $pagSeguro_item->setId($cont++);
         $pagSeguro_item->setDescription(Tools::truncate($product['name'], 255));
         $pagSeguro_item->setQuantity($product['quantity']);
         $pagSeguro_item->setAmount($product['price_wt']);
         $pagSeguro_item->setWeight($product['weight'] * 1000);
         /* Defines weight in grams */
         if ($product['additional_shipping_cost'] > 0) {
             $pagSeguro_item->setShippingCost($product['additional_shipping_cost']);
         }
         array_push($pagseguro_items, $pagSeguro_item);
     }
     return $pagseguro_items;
 }
 /**
  * Generates products data to PagSeguro transaction
  * @param VirtueMartCart $cart
  * @return array
  */
 private function _generateProductsData($order)
 {
     $weightClass = hikashop_get('helper.weight');
     $pagSeguroItems = array();
     $cont = 1;
     $class = hikashop_get('class.product');
     foreach ($order->cart->products as $product) {
         if (!$product->order_product_quantity) {
             continue;
         }
         $product_data = $class->get($product->product_id);
         if (!empty($product->product_parent_id) && $product_data->product_weight <= 0) {
             $product_data = $class->get($product->product_parent_id);
         }
         $product_weight = (int) $weightClass->convert($product_data->product_weight, $product_data->product_weight_unit, 'g');
         $pagSeguroItem = new PagSeguroItem();
         $pagSeguroItem->setId($cont++);
         $pagSeguroItem->setDescription(strip_tags($product->order_product_name));
         $pagSeguroItem->setQuantity($product->order_product_quantity);
         $pagSeguroItem->setAmount(round(PagSeguroHelper::decimalFormat($product->order_product_price), 2));
         $pagSeguroItem->setWeight($product_weight);
         // defines weight in gramas
         array_push($pagSeguroItems, $pagSeguroItem);
     }
     return $pagSeguroItems;
 }
Пример #8
0
 private function getItensInformation()
 {
     $Itens = $this->order->getAllVisibleItems();
     $PagSeguroItens = array();
     $orderType = $this->getOrderType();
     if ($orderType == 'LISTA') {
         //CarShop Items
         foreach ($Itens as $item) {
             $PagSeguroItem = new PagSeguroItem();
             $PagSeguroItem->setId($item->getId());
             $PagSeguroItem->setDescription(self::fixStringLength($item->getName(), 255));
             $PagSeguroItem->setQuantity(self::toFloat($item->getQtyOrdered()));
             $PagSeguroItem->setWeight(round($item->getWeight()));
             $PagSeguroItem->setAmount(self::toFloat($item->getPrice()));
             array_push($PagSeguroItens, $PagSeguroItem);
         }
     } else {
         $storeName = Mage::getModel('core/store')->load($this->order->getStoreId())->getFrontendName();
         // get store name
         $PagSeguroItemCustom = new PagSeguroItem();
         $PagSeguroItemCustom->setId($this->order->getId());
         // get order id
         $PagSeguroItemCustom->setDescription($storeName . " - Pedido " . $this->order->getRealOrderId());
         // ou getIncrementId() -> get order 'cute' number
         $PagSeguroItemCustom->setQuantity(self::toFloat(1));
         // set item qty
         $PagSeguroItemCustom->setWeight(round($this->order->getWeight()));
         // get order total weight
         $PagSeguroItemCustom->setAmount(self::toFloat($this->order->getGrandTotal()));
         // get order total value (including any discounts)
         array_push($PagSeguroItens, $PagSeguroItemCustom);
     }
     return $PagSeguroItens;
 }
Пример #9
0
 /**
  * Generates products data to PagSeguro transaction
  * @param VirtueMartCart $cart
  * @return array
  */
 private function _generateProductsData(VirtueMartCart $cart)
 {
     $pagSeguroItems = array();
     $cont = 1;
     foreach ($cart->products as $key => $product) {
         $pagSeguroItem = new PagSeguroItem();
         $pagSeguroItem->setId($cont++);
         $pagSeguroItem->setDescription($product->product_name);
         $pagSeguroItem->setQuantity($product->quantity);
         $pagSeguroItem->setAmount(number_format($this->calculePrice($cart, $key), 2));
         $pagSeguroItem->setWeight((int) ShopFunctions::convertWeigthUnit($product->product_weight, $product->product_weight_uom, 'G'));
         // defines weight in gramas
         array_push($pagSeguroItems, $pagSeguroItem);
     }
     return $pagSeguroItems;
 }