当前位置: 首页>>代码示例>>PHP>>正文


PHP shopFunctions::getCountrybyID方法代码示例

本文整理汇总了PHP中shopFunctions::getCountrybyID方法的典型用法代码示例。如果您正苦于以下问题:PHP shopFunctions::getCountrybyID方法的具体用法?PHP shopFunctions::getCountrybyID怎么用?PHP shopFunctions::getCountrybyID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shopFunctions的用法示例。


在下文中一共展示了shopFunctions::getCountrybyID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addTransaction

 /**
  * @static
  * @param $method
  * @param $order
  * @param $klarna_pclass
  * @return array|bool
  * @throws Exception
  */
 public static function addTransaction($method, $order, $klarna_pclass)
 {
     if (!class_exists('KlarnaAddr')) {
         require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'api' . DS . 'klarnaaddr.php';
     }
     $session = JFactory::getSession();
     $sessionKlarna = $session->get('Klarna', 0, 'vm');
     $sessionKlarnaData = (object) json_decode($sessionKlarna, true);
     if (!isset($sessionKlarnaData)) {
         throw new Exception("No klarna Session data set");
     }
     $klarnaData = $sessionKlarnaData->KLARNA_DATA;
     // let's put it back as an array
     $klarnaData = (array) $klarnaData;
     if (VMKLARNA_SHIPTO_SAME_AS_BILLTO) {
         $shipTo = $order['details']['BT'];
     } else {
         $shipTo = (!isset($order['details']['ST']) or empty($order['details']['ST']) or count($order['details']['ST']) == 0) ? $order['details']['BT'] : $order['details']['ST'];
     }
     $billTo = $order['details']['BT'];
     $country = shopFunctions::getCountrybyID($shipTo->virtuemart_country_id, 'country_3_code');
     $cData = self::countryData($method, $country);
     //$total_price_excl_vat = self::convertPrice($order['details']['BT']->order_subtotal, $cData['currency_code']);
     //$total_price_incl_vat = self::convertPrice($order['details']['BT']->order_subtotal + $order['details']['BT']->order_tax, $cData['currency_code'], $order['details']['BT']->order_currency);
     $mode = KlarnaHandler::getKlarnaMode($method, $cData['country_code_3']);
     $ssl = KlarnaHandler::getKlarnaSSL($mode);
     // Instantiate klarna object.
     $klarna = new Klarna_virtuemart();
     $klarna->config($cData['eid'], $cData['secret'], $cData['country_code'], $cData['language'], $cData['currency_code'], $mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $ssl);
     // Sets order id's from other systems for the upcoming transaction.
     $klarna->setEstoreInfo($order['details']['BT']->order_number);
     // Fill the good list the we send to Klarna
     foreach ($order['items'] as $item) {
         if ($item->product_basePriceWithTax != 0.0) {
             if ($item->product_basePriceWithTax != $item->product_final_price) {
                 $price = $item->product_basePriceWithTax;
             } else {
                 $price = $item->product_final_price;
             }
         } else {
             if ($item->product_priceWithoutTax != $item->product_item_price) {
                 $price = $item->product_item_price;
             } else {
                 $price = $item->product_discountedPriceWithoutTax;
             }
         }
         $item_price = self::convertPrice($price, $order['details']['BT']->order_currency, $cData['currency_code']);
         $item_price = (double) round($item_price, 2);
         $item_tax_percent = 0;
         foreach ($order['calc_rules'] as $calc_rule) {
             if ($calc_rule->virtuemart_order_item_id == $item->virtuemart_order_item_id and $calc_rule->calc_kind == 'VatTax') {
                 $item_tax_percent = $calc_rule->calc_value;
                 break;
             }
         }
         //$item_discount_percent = (double)(round (abs (($item->product_subtotal_discount / $item->product_quantity) * 100 / $price), 2));
         $item_discount_percent = 0.0;
         $discount_tax_percent = 0.0;
         $klarna->addArticle($item->product_quantity, utf8_decode($item->order_item_sku), utf8_decode(strip_tags($item->order_item_name)), $item_price, (double) $item_tax_percent, $item_discount_percent, KlarnaFlags::INC_VAT);
         $discount_tax_percent = 0.0;
         $includeVat = KlarnaFlags::INC_VAT;
         if ($item->product_subtotal_discount != 0.0) {
             if ($item->product_subtotal_discount > 0.0) {
                 $discount_tax_percent = $item_tax_percent;
                 $includeVat = 0;
             }
             $name = utf8_decode(strip_tags($item->order_item_name)) . ' (' . vmText::_('VMPAYMENT_KLARNA_PRODUCTDISCOUNT') . ')';
             $discount = self::convertPrice(abs($item->product_subtotal_discount), $order['details']['BT']->order_currency, $cData['currency_code']);
             $discount = (double) round(abs($discount), 2) * -1;
             $klarna->addArticle(1, utf8_decode($item->order_item_sku), $name, $discount, (double) $discount_tax_percent, $item_discount_percent, $includeVat);
         }
     }
     // this is not correct yet
     /*
     foreach($order['calc_rules'] as $rule){
     	if ($rule->calc_kind == 'DBTaxRulesBill' or $rule->calc_kind == 'taxRulesBill' or $rule->calc_kind == 'DATaxRulesBill') {
     		$klarna->addArticle (1, "", $rule->calc_rule_name, $rule->calc_amount, 0.0, 0.0, 0);
     
     	}
     
     }
     */
     // Add shipping
     $shipment = self::convertPrice($order['details']['BT']->order_shipment + $order['details']['BT']->order_shipment_tax, $order['details']['BT']->order_currency, $cData['currency_code']);
     foreach ($order['calc_rules'] as $calc_rule) {
         if ($calc_rule->calc_kind == 'shipment') {
             $shipment_tax_percent = $calc_rule->calc_value;
             break;
         }
     }
     $klarna->addArticle(1, "shippingfee", vmText::_('VMPAYMENT_KLARNA_SHIPMENT'), (double) round($shipment, 2), round($shipment_tax_percent, 2), 0, KlarnaFlags::IS_SHIPMENT + KlarnaFlags::INC_VAT);
     // Add invoice fee
//.........这里部分代码省略.........
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:101,代码来源:klarnahandler.php

示例2: addTransaction

 public static function addTransaction($method, $order, $klarna_pclass)
 {
     if (!class_exists('KlarnaAddr')) {
         require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'api' . DS . 'klarnaaddr.php';
     }
     $session = JFactory::getSession();
     $sessionKlarna = $session->get('Klarna', 0, 'vm');
     $sessionKlarnaData = unserialize($sessionKlarna);
     if (!isset($sessionKlarnaData)) {
         throw new Exception("No klarna Session data set");
     }
     $klarnaData = $sessionKlarnaData->KLARNA_DATA;
     //
     $shipTo = (!isset($order['details']['ST']) or empty($order['details']['ST']) or count($order['details']['ST']) == 0) ? $order['details']['BT'] : $order['details']['ST'];
     $billTo = $order['details']['BT'];
     $country = shopFunctions::getCountrybyID($shipTo->virtuemart_country_id, 'country_3_code');
     $cData = self::countryData($method, $country);
     //$total_price_excl_vat = self::convertPrice($order['details']['BT']->order_subtotal, $cData['currency_code']);
     //$total_price_incl_vat = self::convertPrice($order['details']['BT']->order_subtotal + $order['details']['BT']->order_tax, $cData['currency_code'], $order['details']['BT']->order_currency);
     $mode = KlarnaHandler::getKlarnaMode($method);
     $ssl = KlarnaHandler::getKlarnaSSL($mode);
     // Instantiate klarna object.
     $klarna = new Klarna_virtuemart();
     $klarna->config($cData['eid'], $cData['secret'], $cData['country_code'], NULL, $cData['currency_code'], $mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $ssl);
     // Fill the good list the we send to Klarna
     foreach ($order['items'] as $item) {
         $item_price = self::convertPrice($item->product_final_price, $cData['currency_code']);
         $item_price = (double) round($item_price, 2);
         $item_tax_percent = (double) round(self::getTaxPercent($item->product_item_price + $item->product_tax / $item->product_quantity, $item->product_item_price), 2);
         $item_discount = self::convertPrice($item->product_subtotal_discount / $item->product_quantity, $cData['currency_code']);
         $item_discount = (double) abs(round($item_discount, 2));
         //vmdebug('addarticle', $item->order_item_sku, $item,  $item_tax_percent);
         $klarna->addArticle($item->product_quantity, utf8_decode($item->order_item_sku), utf8_decode(strip_tags($item->order_item_name)), $item_price, (double) $item_tax_percent, $item_discount, KlarnaFlags::INC_VAT);
     }
     // Add shipping
     $shipment = self::convertPrice($order['details']['BT']->order_shipment + $order['details']['BT']->order_shipment_tax, $cData['currency_code']);
     $shipment_tax_percent = self::getTaxPercent($order['details']['BT']->order_shipment + $order['details']['BT']->order_shipment_tax, $order['details']['BT']->order_shipment);
     $klarna->addArticle(1, "shippingfee", JText::_('VMPAYMENT_KLARNA_SHIPMENT'), (double) round($shipment, 2), (double) $shipment_tax_percent, 0, KlarnaFlags::IS_SHIPMENT + KlarnaFlags::INC_VAT);
     // Add invoice fee
     if ($klarna_pclass == -1) {
         //Only for invoices!
         $payment = self::convertPrice($order['details']['BT']->order_payment + $order['details']['BT']->order_payment_tax, $cData['currency_code']);
         $payment_tax_percent = self::getTaxPercent($order['details']['BT']->order_payment + $order['details']['BT']->order_payment_tax, $order['details']['BT']->order_payment);
         if ($payment > 0) {
             //vmdebug('invoicefee', $payment, $payment_tax);
             $klarna->addArticle(1, "invoicefee", JText::_('VMPAYMENT_KLARNA_INVOICE_FEE_TITLE'), (double) round($payment, 2), (double) round($payment_tax_percent, 2), 0, KlarnaFlags::IS_HANDLING + KlarnaFlags::INC_VAT);
         }
     }
     // Add coupon if there is any
     if ($order['details']['BT']->coupon_discount > 0) {
         $coupon_discount = self::convertPrice(round($order['details']['BT']->coupon_discount, $cData['currency_code']));
         //vmdebug('discount', $coupon_discount);
         $klarna->addArticle(1, 'discount', JText::_('VMPAYMENT_KLARNA_DISCOUNT') . ' ' . $order['details']['BT']->coupon_code, (int) (round($coupon_discount, 2) * -1), 0, 0, KlarnaFlags::INC_VAT);
     }
     try {
         $klarna_shipping = new KlarnaAddr($order['details']['BT']->email, $shipTo->phone_1, '', utf8_decode($shipTo->first_name), utf8_decode($shipTo->last_name), '', utf8_decode($shipTo->address_1), $shipTo->zip, utf8_decode($shipTo->city), utf8_decode($cData['country']), $shipTo->house_no, $shipTo->address_2);
     } catch (Exception $e) {
         VmInfo($e->getMessage());
         return false;
     }
     if ($klarnaData['invoice_type'] == 'company') {
         $klarna_shipping->isCompany = true;
         $klarna_shipping->setCompanyName($klarna_company_name);
         $klarna_comment = $shipTo->first_name . ' ' . $shipTo->last_name;
         //$klarnaData['reference'];
         if ($klarna_shipping->getLastName() == "") {
             $klarna_shipping->setLastName("-");
         }
         if ($klarna_shipping->getFirstName() == "") {
             $klarna_shipping->setFirstName("-");
         }
     } else {
         $klarna_reference = "";
         $klarna_comment = "";
     }
     // Only allow billing and shipping to be the same for Germany and the Netherlands
     if (VMKLARNA_SHIPTO_SAME_AS_BILLTO) {
         $klarna_billing = $klarna_shipping;
     } else {
         $klarna_billing = self::getBilling($cData, $order);
     }
     $klarna_flags = KlarnaFlags::RETURN_OCR;
     // get ocr back from KO.
     $klarna->setComment($klarna_comment);
     $klarna->setReference($klarna_reference, "");
     $pno = self::getPNOfromOrder($billTo, $country);
     try {
         $klarna->setAddress(KlarnaFlags::IS_SHIPPING, $klarna_shipping);
         $klarna->setAddress(KlarnaFlags::IS_BILLING, $klarna_billing);
         if (isset($klarnaData['year_salary'])) {
             $klarna->setIncomeInfo("'yearly_salary'", $klarnaData['year_salary']);
         }
         $result = $klarna->addTransaction($pno, $klarna->getCountry() == KlarnaCountry::DE || $klarna->getCountry() == KlarnaCountry::NL ? $klarnaData['gender'] : NULL, $klarna_flags, $klarna_pclass);
         $result['eid'] = $cData['eid'];
         $result['status_code'] = $result[2];
         $result['status_text'] = JText::_('VMPAYMENT_KLARNA_ORDER_STATUS_TEXT_' . $result[2]);
         return $result;
         //return $result;
     } catch (Exception $e) {
         $result['status_code'] = KlarnaFlags::DENIED;
//.........这里部分代码省略.........
开发者ID:joselapria,项目名称:virtuemart,代码行数:101,代码来源:klarnahandler.php


注:本文中的shopFunctions::getCountrybyID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。