コード例 #1
0
 function displayRawPrice($number, $currency_code = '')
 {
     global $osC_Language;
     if (empty($currency_code) || $this->exists($currency_code) == false) {
         $currency_code = isset($_SESSION['currency']) ? $_SESSION['currency'] : DEFAULT_CURRENCY;
     }
     return $this->currencies[$currency_code]['symbol_right'] . ' ' . number_format(osc_round($number, $this->currencies[$currency_code]['decimal_places']), $this->currencies[$currency_code]['decimal_places'], $osC_Language->getNumericDecimalSeparator(), $osC_Language->getNumericThousandsSeparator()) . ' ' . $this->currencies[$currency_code]['symbol_left'];
 }
コード例 #2
0
ファイル: Currencies.php プロジェクト: kdexter/oscommerce
 public function displayPriceWithTaxRate($price, $tax_rate, $quantity = 1, $force = false, $currency_code = null, $currency_value = null)
 {
     $price = osc_round($price, $this->currencies[DEFAULT_CURRENCY]['decimal_places']);
     if (($force === true || DISPLAY_PRICE_WITH_TAX == '1') && $tax_rate > 0) {
         $price += osc_round($price * ($tax_rate / 100), $this->currencies[DEFAULT_CURRENCY]['decimal_places']);
     }
     return $this->format($price * $quantity, $currency_code, $currency_value);
 }
コード例 #3
0
 function calculate($price, $tax_rate)
 {
     global $osC_Currencies;
     return osc_round($price * $tax_rate / 100, $osC_Currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
 }
コード例 #4
0
ファイル: Tax.php プロジェクト: kdexter/oscommerce
 public function calculate($price, $tax_rate)
 {
     $OSCOM_Currencies = Registry::get('Currencies');
     return osc_round($price * $tax_rate / 100, $OSCOM_Currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
 }
コード例 #5
0
 function process_button()
 {
     global $osC_ShoppingCart, $osC_Tax, $osC_Language, $osC_Currencies, $osC_Session;
     require_once 'includes/classes/product.php';
     require_once 'ext/googlecheckout/googlecart.php';
     require_once 'ext/googlecheckout/googleitem.php';
     require_once 'ext/googlecheckout/googleshipping.php';
     $cart = new GoogleCart(MODULE_PAYMENT_GCHECKOUT_MERCHANT_ID, MODULE_PAYMENT_GCHECKOUT_MERCHANT_KEY, MODULE_PAYMENT_GCHECKOUT_SERVER, MODULE_PAYMENT_GCHECKOUT_CURRENCY);
     //transfer the whole cart
     if (MODULE_PAYMENT_GCHECKOUT_TRANSFER_CART == '1') {
         //products
         $products = $osC_ShoppingCart->getProducts();
         foreach ($products as $product) {
             $name = $product['name'];
             //gift certificate
             if ($product['type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) {
                 $name .= "\n" . ' - ' . $osC_Language->get('senders_name') . ': ' . $product['gc_data']['senders_name'];
                 if ($product['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                     $name .= "\n" . ' - ' . $osC_Language->get('senders_email') . ': ' . $product['gc_data']['senders_email'];
                 }
                 $name .= "\n" . ' - ' . $osC_Language->get('recipients_name') . ': ' . $product['gc_data']['recipients_name'];
                 if ($product['gc_data']['type'] == GIFT_CERTIFICATE_TYPE_EMAIL) {
                     $name .= "\n" . ' - ' . $osC_Language->get('recipients_email') . ': ' . $product['gc_data']['recipients_email'];
                 }
                 $name .= "\n" . ' - ' . $osC_Language->get('message') . ': ' . $product['gc_data']['message'];
             }
             //variants
             $variants_array = array();
             if ($osC_ShoppingCart->hasVariants($product['id'])) {
                 foreach ($osC_ShoppingCart->getVariants($product['id']) as $variants) {
                     $variants_array[$variants['groups_id']] = $variants['variants_values_id'];
                     $name .= "\n" . ' - ' . $variants['groups_name'] . ': ' . $variants['values_name'];
                 }
             }
             //get tax
             $tax = $osC_Tax->getTaxRate($product['tax_class_id'], $osC_ShoppingCart->getTaxingAddress('country_id'), $osC_ShoppingCart->getTaxingAddress('zone_id'));
             if (DISPLAY_PRICE_WITH_TAX == '1') {
                 $price = $osC_Currencies->addTaxRateToPrice($product['final_price'], $tax);
             } else {
                 $price = $product['final_price'] + osc_round($product['final_price'] * ($tax / 100), $osC_Currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
             }
             $osC_Product = new osC_Product($product['id']);
             $gitem = new GoogleItem($name, $osC_Product->getDescription(), intval($product['quantity']), $price);
             $gitem->SetMerchantPrivateItemData(new MerchantPrivateItemData(array('item' => base64_encode(serialize($product)))));
             $gitem->SetMerchantItemId($product['id']);
             $cart->AddItem($gitem);
         }
         //add order totals modules into gcheckout cart as item such as: coupon, gift certificate, low order fee
         //exclude modules: sub_total, tax, total and shipping module
         $shipping_cost = 0;
         foreach ($osC_ShoppingCart->getOrderTotals() as $total) {
             if (!in_array($total['code'], $this->_ignore_order_totals) && strstr($total['code'], 'shipping') === FALSE) {
                 $gitem = new GoogleItem($total['title'], '', '1', $total['value'] + $total['tax']);
                 $gitem->SetMerchantPrivateItemData(new MerchantPrivateItemData(array('order_total' => base64_encode(serialize($total)))));
                 $cart->AddItem($gitem);
             } else {
                 if (strstr($total['code'], 'shipping') !== FALSE) {
                     $shipping_cost = $total['value'] + $total['tax'];
                 }
             }
         }
         //shipping method
         $cart->AddShipping(new GooglePickUp($osC_ShoppingCart->getShippingMethod('title'), $shipping_cost));
     } else {
         $gitem = new GoogleItem(STORE_NAME, '', 1, $osC_ShoppingCart->getTotal());
         $gitem->SetMerchantPrivateItemData(new MerchantPrivateItemData(array('item' => base64_encode(serialize(STORE_NAME)))));
         $cart->AddItem($gitem);
     }
     //continue shopping url
     $cart->SetContinueShoppingUrl(osc_href_link(FILENAME_CHECKOUT, 'process', 'NOSSL', null, null, true));
     //edit cart url
     $cart->SetEditCartUrl(osc_href_link(FILENAME_CHECKOUT, '', 'NOSSL', null, null, true));
     // Request buyer's phone number
     $cart->SetRequestBuyerPhone(false);
     $private_data = $osC_Session->getID() . ';' . $osC_Session->getName();
     $cart->SetMerchantPrivateData(new MerchantPrivateData(array('orders_id' => $this->_order_id, 'session-data' => $private_data)));
     // Display Google Checkout button
     return $cart->CheckoutButtonCode();
 }