$tmpcontent .= '<td>&nbsp;</td>';
            $tmpcontent .= '<td>&nbsp;</td>';
            $tmpcontent .= '<td>&nbsp;</td>';
            $tmpcontent .= '</tr>';
            if (!isset($this->get['edit_product'])) {
                $tmpcontent .= '<tr><td colspan="' . $colspan . '" style="text-align:left;"><a href="#" id="button_manual_new_product" class="btn btn-success">' . $this->pi_getLL('add_manual_product', 'ADD ITEM') . '</a></td></tr>';
            }
        } else {
            $colspan = 7;
        }
        //		$tmpcontent.='<tr><td colspan="'.$colspan.'"><hr class="hr"></td></tr>';
        $orders_tax_data = unserialize($orders['orders_tax_data']);
        $tmpcontent .= '<tr><td align="right" colspan="' . $colspan . '" class="">';
        if ($this->ms['MODULES']['ORDER_EDIT'] and !$orders['is_locked']) {
            $payment_method = mslib_fe::getPaymentMethod($orders['payment_method'], 'p.code');
            $shipping_method = mslib_fe::getShippingMethod($orders['shipping_method'], 's.code');
            if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                $shipping_costs = mslib_fe::currency() . ' <input type="text" id="display_shipping_method_cost" value="' . round($orders['shipping_method_costs'] + $orders_tax_data['shipping_tax'], 4) . '" class="align_right" style="width:60px">
				<input name="tx_multishop_pi1[shipping_method_costs]" type="hidden" value="' . $orders['shipping_method_costs'] . '">
				<input type="hidden" id="shipping_method_tax_id" value="' . $shipping_method['tax_id'] . '" class="align_right" style="width:60px">';
                $payment_costs = mslib_fe::currency() . ' <input type="text" id="display_payment_method_cost" value="' . round($orders['payment_method_costs'] + $orders_tax_data['payment_tax'], 4) . '" class="align_right" style="width:60px">
				<input name="tx_multishop_pi1[payment_method_costs]" type="hidden" value="' . $orders['payment_method_costs'] . '">
				<input type="hidden" id="payment_method_tax_id" value="' . $payment_method['tax_id'] . '" class="align_right" style="width:60px">
				';
            } else {
                $shipping_costs = '<input name="tx_multishop_pi1[shipping_method_costs]" type="text" value="' . round($orders['shipping_method_costs'], 4) . '" class="align_right" style="width:60px">';
                $payment_costs = '<input name="tx_multishop_pi1[payment_method_costs]" type="text" value="' . round($orders['payment_method_costs'], 4) . '" class="align_right" style="width:60px">';
            }
        } else {
            if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                $shipping_costs = mslib_fe::amount2Cents($orders['shipping_method_costs'] + $orders_tax_data['shipping_tax'], 0);
}
if (count($mapped_shipping_methods)) {
    $available_sid = array();
    foreach ($mapped_shipping_methods as $shipping_method_name => $mapped_shipping_method) {
        $available_sid[] = $mapped_shipping_method['id'];
    }
}
//
if (count($available_sid) > 0) {
    //if (!$this->ms['MODULES']['PRODUCT_EDIT_METHOD_FILTER']) {
    if (!$this->post['tx_multishop_pi1']['sid'] or !in_array($this->post['tx_multishop_pi1']['sid'], $available_sid)) {
        // if the posted shipping id is not in the available shipping method array then select the first valid shipping method
        $this->post['tx_multishop_pi1']['sid'] = $available_sid[0];
    }
    //}
    $shipping_method = mslib_fe::getShippingMethod($this->post['tx_multishop_pi1']['sid'], 's.id', $countries_id, true);
    $shipping_method_code = $shipping_method['code'];
    if (strlen($shipping_method['name']) > 1) {
        $char = substr($shipping_method['name'], 1, 1);
        if ($char == mslib_befe::strtolower($char)) {
            $shipping_method['name'] = $shipping_method['name'];
        }
    } else {
        $shipping_method['name'] = $shipping_method['name'];
    }
    $shipping_method_label = $shipping_method['name'];
    // shipping
    $price = '';
    $priceArray = mslib_fe::getShippingCosts($countries_id, $this->post['tx_multishop_pi1']['sid']);
    if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
        $data['shipping_cost'] = '';
 function setShippingMethod($shipping_method)
 {
     if (!$shipping_method) {
         return 0;
     }
     if (isset($this->cart['user']['delivery_countries_id']) && !empty($this->cart['user']['delivery_countries_id'])) {
         $priceArray = mslib_fe::getShippingCosts($this->cart['user']['delivery_countries_id'], $shipping_method);
     } else {
         $priceArray = mslib_fe::getShippingCosts($this->cart['user']['countries_id'], $shipping_method);
     }
     $price = $priceArray['shipping_costs'];
     if ($price) {
         $this->cart['user']['shipping_method_costs'] = $price;
     } else {
         $this->cart['user']['shipping_method_costs'] = 0;
     }
     if (isset($this->cart['user']['delivery_countries_id']) && !empty($this->cart['user']['delivery_countries_id'])) {
         $shipping_method = mslib_fe::getShippingMethod($shipping_method, 's.id', $this->cart['user']['delivery_countries_id']);
     } else {
         $shipping_method = mslib_fe::getShippingMethod($shipping_method, 's.id', $this->cart['user']['countries_id']);
     }
     if ($shipping_method['tax_id'] && $this->cart['user']['shipping_method_costs']) {
         $this->cart['user']['shipping_total_tax_rate'] = $shipping_method['tax_rate'];
         if ($shipping_method['country_tax_rate']) {
             $this->cart['user']['shipping_country_tax_rate'] = $shipping_method['country_tax_rate'];
             $this->cart['user']['shipping_country_tax'] = mslib_fe::taxDecimalCrop($this->cart['user']['shipping_method_costs'] * $shipping_method['country_tax_rate']);
         } else {
             $this->cart['user']['shipping_country_tax_rate'] = 0;
             $this->cart['user']['shipping_country_tax'] = 0;
         }
         if ($shipping_method['region_tax_rate']) {
             $this->cart['user']['shipping_region_tax_rate'] = $shipping_method['region_tax_rate'];
             $this->cart['user']['shipping_region_tax'] = mslib_fe::taxDecimalCrop($this->cart['user']['shipping_method_costs'] * $shipping_method['region_tax_rate']);
         } else {
             $this->cart['user']['shipping_region_tax_rate'] = 0;
             $this->cart['user']['shipping_region_tax'] = 0;
         }
         if ($this->cart['user']['shipping_region_tax'] && $this->cart['user']['shipping_country_tax']) {
             $this->cart['user']['shipping_tax'] = $this->cart['user']['shipping_country_tax'] + $this->cart['user']['shipping_region_tax'];
         } else {
             $this->cart['user']['shipping_tax'] = mslib_fe::taxDecimalCrop($this->cart['user']['shipping_method_costs'] * $shipping_method['tax_rate']);
         }
     } else {
         $this->cart['user']['shipping_tax'] = 0;
         $this->cart['user']['shipping_country_tax'] = 0;
         $this->cart['user']['shipping_region_tax'] = 0;
         $this->cart['user']['shipping_total_tax_rate'] = 0;
         $this->cart['user']['shipping_country_tax_rate'] = 0;
         $this->cart['user']['shipping_region_tax_rate'] = 0;
     }
     $this->cart['user']['shipping_method'] = $shipping_method['code'];
     $this->cart['user']['shipping_method_label'] = $shipping_method['name'];
     // hook to rewrite the whole methods
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_cart.php']['setShippingMethodPreSaveHook'])) {
         $params = array('cart_user' => &$this->cart['user']);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_cart.php']['setShippingMethodPreSaveHook'] as $funcRef) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
     tx_mslib_cart::storeCart($this->cart);
 }
		';
    }
    if (count($shipping_methods)) {
        $content .= '
		<div id="multishopShippingMethodWrapper">
		<div class="main-heading"><h2>' . $this->pi_getLL('choose_shipping_method') . '</h2></div>
		<ul id="multishopShippingMethod" class="row">';
        $count = 0;
        $delivery_country = $cart['user']['country'];
        if (isset($cart['user']['different_delivery_address']) && !empty($cart['user']['different_delivery_address']) && isset($cart['user']['delivery_country']) && !empty($cart['user']['delivery_country'])) {
            $delivery_country = $cart['user']['delivery_country'];
        }
        $tmp_countries = mslib_fe::getCountryByName($delivery_country);
        $countries_id = $tmp_countries['cn_iso_nr'];
        foreach ($shipping_methods as $code => $item) {
            $shipping_method = mslib_fe::getShippingMethod($item['id'], 's.id', $countries_id);
            // custom hook that can be controlled by third-party plugin
            $shipping_method_description = '';
            if (!empty($item['description'])) {
                $shipping_method_description = '<div class="description">' . $item['description'] . '</div>';
            }
            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/front_pages/includes/checkout/multistep/checkout_shipping_payment_method']['checkoutMultistepShippingMethodSelectionHook'])) {
                $params = array('shipping_method' => &$shipping_method, 'item' => &$item, 'shipping_method_description' => &$shipping_method_description);
                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/front_pages/includes/checkout/multistep/checkout_shipping_payment_method']['checkoutMultistepShippingMethodSelectionHook'] as $funcRef) {
                    \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
                }
            }
            $count++;
            // costs
            $price_wrap = '';
            $priceArray = mslib_fe::getShippingCosts($countries_id, $item['id']);
Beispiel #5
0
 public function productFeedGeneratorGetShippingCosts($products, $countries_id, $shipping_method_id)
 {
     if (!is_array($products) && count($products)) {
         return false;
     }
     if (!is_numeric($countries_id)) {
         return false;
     }
     if (!is_numeric($shipping_method_id)) {
         return false;
     }
     $str3 = $GLOBALS['TYPO3_DB']->SELECTquery('sm.shipping_costs_type, sm.handling_costs, c.price, c.override_shippingcosts, c.zone_id', 'tx_multishop_shipping_methods sm, tx_multishop_shipping_methods_costs c, tx_multishop_countries_to_zones c2z', 'sm.id=c.shipping_method_id and c.zone_id=c2z.zone_id and c.shipping_method_id=\'' . $shipping_method_id . '\' and (sm.page_uid=0 or sm.page_uid=\'' . $this->shop_pid . '\') and c2z.cn_iso_nr=\'' . $countries_id . '\'', '', '', '');
     $qry3 = $GLOBALS['TYPO3_DB']->sql_query($str3);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry3)) {
         $row3 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry3);
         $shipping_method = mslib_fe::getShippingMethod($shipping_method_id, 's.id', $countries_id);
         //hook to let other plugins further manipulate the settings
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['productFeedGeneratorGetShippingCosts'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['productFeedGeneratorGetShippingCosts'] as $funcRef) {
                 $params['row3'] =& $row3;
                 $params['shipping_method'] =& $shipping_method;
                 $params['countries_id'] =& $countries_id;
                 \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
             }
         }
         if ($row3['shipping_costs_type'] == 'weight') {
             $total_weight = $products['products_weight'];
             $steps = explode(",", $row3['price']);
             $current_price = '';
             foreach ($steps as $step) {
                 $cols = explode(":", $step);
                 if (isset($cols[1])) {
                     $current_price = $cols[1];
                 }
                 if ($total_weight <= $cols[0]) {
                     $current_price = $cols[1];
                     break;
                 }
             }
             $shipping_cost = $current_price;
             $shipping_cost_method_box = $current_price;
         } elseif ($row3['shipping_costs_type'] == 'quantity') {
             $total_quantity = 1;
             $steps = explode(",", $row3['price']);
             $current_price = '';
             foreach ($steps as $step) {
                 $cols = explode(":", $step);
                 if (isset($cols[1])) {
                     $current_price = $cols[1];
                 }
                 if ($total_quantity <= $cols[0]) {
                     $current_price = $cols[1];
                     break;
                 }
             }
             $shipping_cost = $current_price;
             $shipping_cost_method_box = $current_price;
         } else {
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['productFeedGeneratorGetShippingCostsCustomType'])) {
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['productFeedGeneratorGetShippingCostsCustomType'] as $funcRef) {
                     $params['products'] =& $products;
                     $params['row3'] =& $row3;
                     $params['countries_id'] =& $countries_id;
                     $params['shipping_method'] =& $shipping_method;
                     $params['shipping_method_id'] =& $shipping_method_id;
                     $params['shipping_cost'] =& $shipping_cost;
                     $params['shipping_cost_method_box'] =& $shipping_cost_method_box;
                     \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
                 }
             } else {
                 $shipping_cost = $row3['price'];
                 $shipping_cost_method_box = $row3['price'];
             }
         }
         //
         // calculate total costs
         $subtotal = $products['final_price'];
         if (strstr($subtotal, ",")) {
             $subtotal = str_replace(',', '.', $subtotal);
         }
         //
         if (!empty($row3['override_shippingcosts'])) {
             $old_shipping_costs = $shipping_cost;
             $shipping_cost = $row3['override_shippingcosts'];
             // custom code to change the shipping costs based on cart amount
             if (strstr($shipping_cost, ",") || strstr($shipping_cost, ":")) {
                 $steps = explode(",", $shipping_cost);
                 $count = 0;
                 if (is_array($steps) && count($steps)) {
                     foreach ($steps as $step) {
                         // example: the value 200:15 means below 200 euro the shipping costs are 15 euro, above and equal 200 euro the shipping costs are 0 euro
                         // example setting: 0:6.95,50:0
                         $split = explode(":", $step);
                         if (is_numeric($split[0])) {
                             if ($subtotal > $split[0] and isset($split[1])) {
                                 $shipping_cost = $split[1];
                                 $shipping_cost_method_box = $split[1];
                                 continue;
                             } else {
                                 $shipping_cost = $old_shipping_costs;
                                 $shipping_cost_method_box = $old_shipping_costs;
                             }
                         }
                         $count++;
                     }
                 }
             }
         }
         // custom code to change the shipping costs based on cart amount
         if (strstr($shipping_cost, ",") || strstr($shipping_cost, ":")) {
             $steps = explode(",", $shipping_cost);
             $count = 0;
             foreach ($steps as $step) {
                 // example: the value 200:15 means below 200 euro the shipping costs are 15 euro, above and equal 200 euro the shipping costs are 0 euro
                 // example setting: 0:6.95,50:0
                 $split = explode(":", $step);
                 if (is_numeric($split[0])) {
                     if ($count == 0) {
                         if (isset($split[1])) {
                             $shipping_cost = $split[1];
                             $shipping_cost_method_box = $split[1];
                         } else {
                             $shipping_cost = $split[0];
                             $shipping_cost_method_box = $split[0];
                             continue;
                         }
                     }
                     if ($subtotal > $split[0] and isset($split[1])) {
                         $shipping_cost = $split[1];
                         $shipping_cost_method_box = $split[0];
                         continue;
                     }
                 }
                 $count++;
             }
         }
         // custom code to change the shipping costs based on cart amount
         if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
             $shipping_cost = round($shipping_cost, 2);
             $shipping_cost_method_box = round($shipping_cost_method_box, 2);
         }
         // shipping costs only for shipping method box display
         if ($shipping_cost_method_box) {
             if ($shipping_method['tax_id'] && $shipping_cost_method_box) {
                 $shipping_method_box_total_tax_rate = $shipping_method['tax_rate'];
                 if ($shipping_method['country_tax_rate']) {
                     $shipping_method_box_country_tax_rate = $shipping_method['country_tax_rate'];
                     $shipping_method_box_country_tax = mslib_fe::taxDecimalCrop($shipping_cost_method_box * $shipping_method['country_tax_rate']);
                 } else {
                     $shipping_method_box_country_tax_rate = 0;
                     $shipping_method_box_country_tax = 0;
                 }
                 if ($shipping_method['region_tax_rate']) {
                     $shipping_method_box_region_tax_rate = $shipping_method['region_tax_rate'];
                     $shipping_method_box_region_tax = mslib_fe::taxDecimalCrop($shipping_cost_method_box * $shipping_method['region_tax_rate']);
                 } else {
                     $shipping_method_box_region_tax_rate = 0;
                     $shipping_method_box_region_tax = 0;
                 }
                 if ($shipping_method_box_region_tax && $shipping_method_box_country_tax) {
                     $shipping_method_box_tax = $shipping_method_box_country_tax + $shipping_method_box_region_tax;
                 } else {
                     $shipping_method_box_tax = mslib_fe::taxDecimalCrop($shipping_cost_method_box * $shipping_method['tax_rate']);
                 }
             }
         }
         if ($shipping_cost) {
             if ($shipping_method['tax_id'] && $shipping_cost) {
                 $shipping_total_tax_rate = $shipping_method['tax_rate'];
                 if ($shipping_method['country_tax_rate']) {
                     $shipping_country_tax_rate = $shipping_method['country_tax_rate'];
                     $shipping_country_tax = mslib_fe::taxDecimalCrop($shipping_cost * $shipping_method['country_tax_rate']);
                 } else {
                     $shipping_country_tax_rate = 0;
                     $shipping_country_tax = 0;
                 }
                 if ($shipping_method['region_tax_rate']) {
                     $shipping_region_tax_rate = $shipping_method['region_tax_rate'];
                     $shipping_region_tax = mslib_fe::taxDecimalCrop($shipping_cost * $shipping_method['region_tax_rate']);
                 } else {
                     $shipping_region_tax_rate = 0;
                     $shipping_region_tax = 0;
                 }
                 if ($shipping_region_tax && $shipping_country_tax) {
                     $shipping_tax = $shipping_country_tax + $shipping_region_tax;
                 } else {
                     $shipping_tax = mslib_fe::taxDecimalCrop($shipping_cost * $shipping_method['tax_rate']);
                 }
             }
         }
         $handling_cost = 0;
         $handling_tax = 0;
         if (!empty($row3['handling_costs'])) {
             $handling_cost = $row3['handling_costs'];
             if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                 $handling_cost = round($row3['handling_costs'], 2);
             }
             $percentage_handling_cost = false;
             if (strpos($handling_cost, '%') !== false) {
                 $handling_cost = str_replace('%', '', $handling_cost);
                 $percentage_handling_cost = true;
             }
             if ($percentage_handling_cost) {
                 $tmp_handling_cost = $handling_cost;
                 if ($products['tax_rate'] && $this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                     $products['final_price'] = $products['final_price'] * (1 + $products['tax_rate']);
                 }
                 $subtotal = $products['final_price'];
                 if ($subtotal) {
                     $handling_cost = $subtotal / 100 * $tmp_handling_cost;
                     if ($total_include_vat && $shipping_method['tax_rate']) {
                         $handling_cost = $handling_cost / (1 + $shipping_method['tax_rate']);
                     }
                 }
             }
             //var_dump($shipping_method['tax_rate']);
             //die();
             if ($shipping_method['tax_id'] && $handling_cost) {
                 $handling_total_tax_rate = $shipping_method['tax_rate'];
                 if ($shipping_method['country_tax_rate']) {
                     $handling_country_tax_rate = $shipping_method['country_tax_rate'];
                     $handling_country_tax = mslib_fe::taxDecimalCrop($handling_cost * $shipping_method['country_tax_rate']);
                 } else {
                     $handling_country_tax_rate = 0;
                     $handling_country_tax = 0;
                 }
                 if ($shipping_method['region_tax_rate']) {
                     $handling_region_tax_rate = $shipping_method['region_tax_rate'];
                     $handling_region_tax = mslib_fe::taxDecimalCrop($handling_cost * $shipping_method['region_tax_rate']);
                 } else {
                     $handling_region_tax_rate = 0;
                     $handling_region_tax = 0;
                 }
                 if ($handling_region_tax && $handling_country_tax) {
                     $handling_tax = $handling_country_tax + $handling_region_tax;
                 } else {
                     $handling_tax = mslib_fe::taxDecimalCrop($handling_cost * $shipping_method['tax_rate']);
                 }
             }
         }
         $shipping_cost += $handling_cost;
         $shipping_tax += $handling_tax;
         $shipping_cost_method_box += $handling_cost;
         $shipping_method_box_tax += $handling_tax;
         $shipping_method['shipping_costs_method_box'] = $shipping_cost_method_box;
         $shipping_method['shipping_costs_method_box_including_vat'] = $shipping_cost_method_box + $shipping_method_box_tax;
         $shipping_method['shipping_costs'] = $shipping_cost;
         $shipping_method['shipping_costs_including_vat'] = $shipping_cost + $shipping_tax;
         return $shipping_method;
     } else {
         return false;
     }
 }
 function repairOrder($orders_id)
 {
     if (is_numeric($orders_id)) {
         $this->conf['order_id'] = (int) $orders_id;
         $tax_separation = array();
         $sql = "select orders_id, orders_tax_data, payment_method_costs, shipping_method_costs, discount, shipping_method, payment_method, billing_region, billing_country, billing_vat_id from tx_multishop_orders where orders_id='" . $orders_id . "' order by orders_id asc";
         $qry = $GLOBALS['TYPO3_DB']->sql_query($sql);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
             $sub_total_tax = 0;
             $sub_total = 0;
             $sub_total_excluding_vat = 0;
             $shipping_tax = 0;
             $payment_tax = 0;
             $grand_total = 0;
             $order_tax_data['shipping_tax'] = '0';
             $order_tax_data['shipping_country_tax'] = '0';
             $order_tax_data['shipping_region_tax'] = '0';
             $order_tax_data['shipping_total_tax_rate'] = '0';
             $order_tax_data['shipping_country_tax_rate'] = '0';
             $order_tax_data['shipping_region_tax_rate'] = '0';
             $order_tax_data['payment_tax'] = '0';
             $order_tax_data['payment_country_tax'] = '0';
             $order_tax_data['payment_region_tax'] = '0';
             $order_tax_data['payment_total_tax_rate'] = '0';
             $order_tax_data['payment_country_tax_rate'] = '0';
             $order_tax_data['payment_region_tax_rate'] = '0';
             $order_tax_data['grand_total'] = '0';
             $order_tax_data['total_orders_tax'] = '0';
             // get shipping method by code
             $this->tta_user_info['default']['country'] = $row['billing_country'];
             $iso_customer = mslib_fe::getCountryByName($this->tta_user_info['default']['country']);
             $iso_customer['country'] = $iso_customer['cn_short_en'];
             // if store country is different from customer country and user provided valid VAT id, change VAT rate to zero
             //$this->ms['MODULES']['DISABLE_VAT_RATE']=0;
             if (!$this->ms['MODULES']['DISABLE_VAT_RATE'] && $this->ms['MODULES']['DISABLE_VAT_FOR_FOREIGN_CUSTOMERS_WITH_COMPANY_VAT_ID'] and $row['billing_vat_id']) {
                 if (strtolower($row['billing_country']) != strtolower($this->tta_shop_info['country'])) {
                     $this->ms['MODULES']['DISABLE_VAT_RATE'] = 1;
                 }
             }
             // get shipping tax rate
             $shipping_method = mslib_fe::getShippingMethod($row['shipping_method'], 's.code', $iso_customer['cn_iso_nr']);
             $tax_rate = mslib_fe::taxRuleSet($shipping_method['tax_id'], 0, $iso_customer['cn_iso_nr'], 0);
             if (!$tax_rate['total_tax_rate']) {
                 $tax_rate['total_tax_rate'] = $this->ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS'];
             }
             if ($this->ms['MODULES']['DISABLE_VAT_RATE']) {
                 $tax_rate['total_tax_rate'] = 0;
             }
             $shipping_tax_rate = $tax_rate['total_tax_rate'] / 100;
             // get payment tax rate
             $payment_method = mslib_fe::getPaymentMethod($row['payment_method'], 'p.code', $iso_customer['cn_iso_nr']);
             $tax_rate = mslib_fe::taxRuleSet($payment_method['tax_id'], 0, $iso_customer['cn_iso_nr'], 0);
             if (!$tax_rate['total_tax_rate']) {
                 $tax_rate['total_tax_rate'] = $this->ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS'];
             }
             if ($this->ms['MODULES']['DISABLE_VAT_RATE']) {
                 $tax_rate['total_tax_rate'] = 0;
             }
             $payment_tax_rate = $tax_rate['total_tax_rate'] / 100;
             if ($shipping_tax_rate > 0 or $payment_tax_rate > 0) {
                 // disable rounding to prevent cents short issue
                 $shipping_tax = $row['shipping_method_costs'] * $shipping_tax_rate;
                 $payment_tax = $row['payment_method_costs'] * $payment_tax_rate;
                 /*if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                 			$shipping_tax=round($row['shipping_method_costs']*$shipping_tax_rate, 2);
                 			$payment_tax=round($row['payment_method_costs']*$payment_tax_rate, 2);
                 		} else {
                 			$shipping_tax=$row['shipping_method_costs']*$shipping_tax_rate;
                 			$payment_tax=$row['payment_method_costs']*$payment_tax_rate;
                 		}*/
                 $order_tax_data['shipping_total_tax_rate'] = (string) number_format($shipping_tax_rate, 2, '.', ',');
                 $order_tax_data['payment_total_tax_rate'] = (string) number_format($payment_tax_rate, 2, '.', ',');
                 $order_tax_data['shipping_tax'] = (string) $shipping_tax;
                 $order_tax_data['payment_tax'] = (string) $payment_tax;
                 //$total_tax+=$shipping_tax+$payment_tax;
                 //$grand_total+=(($row['shipping_method_costs']+$row['payment_method_costs'])+($shipping_tax+$payment_tax));
             } else {
                 //$grand_total+=($row['shipping_method_costs']+$row['payment_method_costs']);
             }
             $tax_separation[$shipping_tax_rate * 100]['shipping_tax'] += $shipping_tax;
             $tax_separation[$payment_tax_rate * 100]['payment_tax'] += $payment_tax;
             $tax_separation[$shipping_tax_rate * 100]['shipping_costs'] = $row['shipping_method_costs'];
             $tax_separation[$payment_tax_rate * 100]['payment_costs'] = $row['payment_method_costs'];
             //
             $product_tax_data['country_tax_rate'] = '0';
             $product_tax_data['region_tax_rate'] = '0';
             $product_tax_data['total_tax_rate'] = '0';
             $product_tax_data['country_tax'] = '0';
             $product_tax_data['region_tax'] = '0';
             $product_tax_data['total_tax'] = '0';
             $product_tax_data['total_attributes_tax'] = '0';
             $sql_prod = "select * from tx_multishop_orders_products where orders_id = " . $row['orders_id'];
             $qry_prod = $GLOBALS['TYPO3_DB']->sql_query($sql_prod);
             while ($row_prod = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_prod)) {
                 $tax_rate = $row_prod['products_tax'] / 100;
                 $product_tax = unserialize($row_prod['products_tax_data']);
                 // attributes tax
                 $sql_attr = "select * from tx_multishop_orders_products_attributes where orders_products_id = " . $row_prod['orders_products_id'] . " and orders_id = " . $row_prod['orders_id'];
                 $qry_attr = $GLOBALS['TYPO3_DB']->sql_query($sql_attr);
                 $attributes_tax = 0;
                 $tmp_attributes_price = 0;
                 $tmp_attributes_tax = 0;
                 while ($row_attr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_attr)) {
                     if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                         // remove the rounding to prevent cents short
                         //$tmp_attributes_tax=round(($row_attr['price_prefix'].$row_attr['options_values_price'])*($tax_rate), 2);
                         $tmp_attributes_tax = ($row_attr['price_prefix'] . $row_attr['options_values_price']) * $tax_rate;
                     } else {
                         $tmp_attributes_tax = mslib_fe::taxDecimalCrop(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $tax_rate);
                     }
                     $attributes_tax += $tmp_attributes_tax;
                     $tmp_attributes_price += $row_attr['price_prefix'] . $row_attr['options_values_price'] * $row_prod['qty'];
                     $sub_total += ($row_attr['price_prefix'] . $row_attr['options_values_price']) * $row_prod['qty'];
                     $sub_total_excluding_vat += $row_attr['price_prefix'] . $row_attr['options_values_price'] * $row_prod['qty'];
                     $grand_total += $row_attr['price_prefix'] . $row_attr['options_values_price'] * $row_prod['qty'];
                     // set the attributes tax data
                     $attributes_tax_data = array();
                     if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                         $attributes_tax_data['country_tax'] = round(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $product_tax['country_tax_rate'], 2);
                         $attributes_tax_data['region_tax'] = round(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $product_tax['region_tax_rate'], 2);
                         if ($attributes_tax_data['country_tax'] && $attributes_tax_data['region_tax']) {
                             $attributes_tax_data['tax'] = $attributes_tax_data['country_tax'] + $attributes_tax_data['region_tax'];
                         } else {
                             $attributes_tax_data['tax'] = round(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $tax_rate, 2);
                         }
                     } else {
                         $attributes_tax_data['country_tax'] = mslib_fe::taxDecimalCrop(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $product_tax['country_tax_rate']);
                         $attributes_tax_data['region_tax'] = mslib_fe::taxDecimalCrop(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $product_tax['region_tax_rate']);
                         if ($attributes_tax_data['country_tax'] && $attributes_tax_data['region_tax']) {
                             $attributes_tax_data['tax'] = $attributes_tax_data['country_tax'] + $attributes_tax_data['region_tax'];
                         } else {
                             $attributes_tax_data['tax'] = mslib_fe::taxDecimalCrop(($row_attr['price_prefix'] . $row_attr['options_values_price']) * $tax_rate);
                         }
                     }
                     $serial_product_attributes_tax = serialize($attributes_tax_data);
                     $sql_update = "update tx_multishop_orders_products_attributes set attributes_tax_data = '" . $serial_product_attributes_tax . "' where orders_products_attributes_id='" . $row_attr['orders_products_attributes_id'] . "' and orders_products_id = " . $row_attr['orders_products_id'] . " and orders_id = " . $row_attr['orders_id'];
                     $GLOBALS['TYPO3_DB']->sql_query($sql_update);
                 }
                 $sub_total_tax += $attributes_tax * $row_prod['qty'];
                 $sub_total += $attributes_tax * $row_prod['qty'];
                 // subtotal including vat
                 $grand_total += $attributes_tax * $row_prod['qty'];
                 $product_tax_data['total_attributes_tax'] = (string) $attributes_tax;
                 $product_tax_data['total_tax_rate'] = (string) number_format($tax_rate, 2, '.', ',');
                 $final_price = $row_prod['final_price'];
                 /*if ($this->ms['MODULES']['ENABLE_DISCOUNT_ON_EDIT_ORDER_PRODUCT']) {
                 			if (!empty($row_prod['discount_amount'])) {
                 				$final_price-=$row_prod['discount_amount'];
                 			}
                 		}*/
                 //print_r($row_prod);
                 // b2b mode 1 cent bugfix: 2013-05-09 cbc in grand total. this came from the products final price that must be round first
                 // I have fixed the b2b issue by updating all the products prices in the database to have max 2 decimals
                 // therefore I disabled below bugfix, cause thats a ducktape solution that can break b2c sites
                 //$final_price=round($final_price,2);
                 /*
                  * the rounding for excluding vat price is causing cents short
                  */
                 /*if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                 			$tax=round($final_price*$tax_rate, 2);
                 		} else {
                 			$tax=$final_price*$tax_rate;
                 		}
                 		*/
                 $tax = $final_price * $tax_rate;
                 $product_tax_data['total_tax'] = (string) $tax;
                 $sub_total_tax += $tax * $row_prod['qty'];
                 $sub_total += ($final_price + $tax) * $row_prod['qty'];
                 $sub_total_excluding_vat += $final_price * $row_prod['qty'];
                 $grand_total += ($final_price + $tax) * $row_prod['qty'];
                 $serial_prod = serialize($product_tax_data);
                 $sql_update = "update tx_multishop_orders_products set products_tax_data = '" . $serial_prod . "' where orders_products_id = " . $row_prod['orders_products_id'] . " and orders_id = " . $row['orders_id'];
                 $GLOBALS['TYPO3_DB']->sql_query($sql_update);
                 // separation of tax
                 $tax_separation[$row_prod['products_tax'] / 100 * 100]['products_total_tax'] += ($tax + $attributes_tax) * $row_prod['qty'];
                 $tax_separation[$row_prod['products_tax'] / 100 * 100]['products_sub_total_excluding_vat'] += ($final_price + $tmp_attributes_price) * $row_prod['qty'];
                 $tax_separation[$row_prod['products_tax'] / 100 * 100]['products_sub_total'] += $final_price + $tmp_attributes_price + ($tax + $attributes_tax) * $row_prod['qty'];
             }
             $order_tax_data['total_orders_tax_including_discount'] = $order_tax_data['total_orders_tax'];
             $order_tax_data['sub_total'] = (string) $sub_total;
             $order_tax_data['sub_total_excluding_vat'] = (string) $sub_total_excluding_vat;
             // discount
             //echo "<pre>";
             //echo $sub_total."<br/>";
             //echo $sub_total_excluding_vat."<br/>";
             if ($row['discount'] < 0 || $row['discount'] > 0) {
                 if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                     $discount_price = round($row['discount'], 2);
                     //$sub_total_excluding_vat-=$discount_price;
                     $discount_percentage = $discount_price / $sub_total_excluding_vat * 100;
                     //$tmp_sub_total=(($sub_total_excluding_vat)/100*(100-$discount_percentage));
                     if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                         $sub_total_tax = round((1 - $discount_price / $sub_total) * $sub_total_tax, 2);
                     } else {
                         $sub_total_tax = ($sub_total - $sub_total_excluding_vat) / 100 * (100 - $discount_percentage);
                     }
                 } else {
                     $discount_price = $row['discount'];
                     //$sub_total-=$discount_price;
                     $discount_percentage = $discount_price / $sub_total * 100;
                     //$tmp_sub_total=(($sub_total)/100*(100-$discount_percentage));
                     //
                     if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                         $sub_total_tax = round((1 - $discount_price / $sub_total) * $sub_total_tax, 2);
                     } else {
                         $sub_total_tax = ($sub_total - $sub_total_excluding_vat) / 100 * (100 - $discount_percentage);
                     }
                 }
                 if (count($tax_separation) > 1) {
                     $tax_separation = array();
                 }
             }
             //echo $discount_percentage."<br/>";
             //echo $discount_price."<br/>";
             //echo $sub_total_tax."<br/>";
             //die();
             $order_tax_data['total_orders_tax'] = (string) $sub_total_tax + $shipping_tax + $payment_tax;
             if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) {
                 $order_tax_data['grand_total'] = (string) ($sub_total_excluding_vat - $discount_price + $sub_total_tax) + ($row['shipping_method_costs'] + $shipping_tax) + ($row['payment_method_costs'] + $payment_tax);
             } else {
                 $order_tax_data['grand_total'] = (string) ($sub_total - $discount_price) + ($row['shipping_method_costs'] + $shipping_tax) + ($row['payment_method_costs'] + $payment_tax);
             }
             $order_tax_data['grand_total_excluding_vat'] = (string) ($sub_total_excluding_vat - $discount_price) + $row['shipping_method_costs'] + $row['payment_method_costs'];
             //
             $order_tax_data['tax_separation'] = $tax_separation;
             //print_r($order_tax_data);
             $serial_orders = serialize($order_tax_data);
             // update orders
             $updateArray = array();
             $updateArray['grand_total'] = round($order_tax_data['grand_total'], 2);
             $updateArray['grand_total_excluding_vat'] = round($order_tax_data['grand_total_excluding_vat'], 2);
             $updateArray['orders_tax_data'] = $serial_orders;
             if ($row['discount'] > 0) {
                 $updateArray['discount'] = $discount_price;
             }
             $updateArray['orders_last_modified'] = time();
             $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_orders', 'orders_id=\'' . $row['orders_id'] . '\'', $updateArray);
             $res = $GLOBALS['TYPO3_DB']->sql_query($query);
             //$sql_update="update tx_multishop_orders set grand_total='".round($order_tax_data['grand_total'], 2)."', orders_tax_data = '".$serial_orders."' where orders_id = ".$row['orders_id'];
             //$GLOBALS['TYPO3_DB']->sql_query($sql_update);
         }
     }
 }
				<div class="radio radio-success radio-inline input_label_wrapper"><input type="radio" name="enable_on_default" value="0" id="enable_on_default_no" /><label for="enable_on_default_no">' . $this->pi_getLL('no') . '</label></div>
			</div>
		</div>
		<div class="form-group">
			<div class="col-md-10 col-md-offset-2">
				<input name="shipping_method_code" type="hidden" value="' . htmlspecialchars($this->get['shipping_method_code']) . '" />
				<input name="sub" type="hidden" value="add_shipping_method" />
				<button name="Submit" class="btn btn-success" type="submit" value=""><i class="fa fa-save"></i> ' . $this->pi_getLL('save') . '</button>
			</div>
		</div>
		</form>';
        $content .= mslib_fe::returnBoxedHTML($shipping_method['name'], $tmpcontent);
        $tmpcontent = '';
    }
} elseif ($this->get['edit']) {
    $row = mslib_fe::getShippingMethod($this->get['shipping_method_id'], 's.id');
    $str = "SELECT * from tx_multishop_shipping_methods_description where id='" . $row['id'] . "'";
    $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
    $lngproduct = array();
    while (($tmprow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) {
        $lngproduct[$tmprow['language_id']] = $tmprow;
    }
    $psp = $shipping_methods[$row['provider']];
    $inner_content = mslib_fe::parseShippingMethodEditForm($psp, unserialize($row['vars']), 1);
    $tmpcontent .= '
	<div class="panel panel-default">
	<div class="panel-body">
	<form id="add_payment_form" class="form-horizontal" action="' . mslib_fe::typolink($this->shop_pid . ',2003', '&tx_multishop_pi1[page_section]=' . $this->ms['page']) . '" method="post">
	<input name="sub" type="hidden" value="update_shipping_method" />
	<input name="shipping_method_id" type="hidden" value="' . $row['id'] . '" />';
    foreach ($this->languages as $key => $language) {
Beispiel #8
0
         $insertArray['status'] = 1;
         $insertArray['provider'] = 'cod';
         $insertArray = mslib_befe::rmNullValuedKeys($insertArray);
         $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_shipping_methods', $insertArray);
         $res = $GLOBALS['TYPO3_DB']->sql_query($query);
         $id = $GLOBALS['TYPO3_DB']->sql_insert_id();
         if ($id) {
             $updateArray = array();
             $updateArray['name'] = $record['shipping_method'];
             $updateArray['description'] = '';
             $updateArray['id'] = $id;
             $updateArray['language_id'] = 0;
             $updateArray = mslib_befe::rmNullValuedKeys($updateArray);
             $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_shipping_methods_description', $updateArray);
             $res = $GLOBALS['TYPO3_DB']->sql_query($query);
             $shipping_method = mslib_fe::getShippingMethod($record['shipping_method'], 'd.name');
         }
     }
     $row['shipping_method'] = $shipping_method['code'];
     $row['shipping_method_label'] = $shipping_method['name'];
 }
 // $row['billing_name']=$record['last_modified'];
 $row['crdate'] = strtotime($record['date_purchased']);
 if ($record['shipping_cost']) {
     // calculate price excluding vat
     $record['shipping_cost'] = $record['shipping_cost'] / (100 + $this->ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']) * 100;
     $row['shipping_method_costs'] = $record['shipping_cost'];
 }
 if ($record['payment_cost']) {
     // calculate price excluding vat
     $record['payment_cost'] = $record['payment_cost'] / (100 + $this->ms['MODULES']['INCLUDE_VAT_OVER_METHOD_COSTS']) * 100;
                        $tmpcontent .= '</tbody>';
                    }
                }
            }
            //echo '<pre>';
            //print_r($order_products_table);
            //die();
            //		$tmpcontent.='<tr><td colspan="'.$colspan.'"><hr class="hr"></td></tr>';
            $orders_tax_data = unserialize($orders['orders_tax_data']);
            $tmpcontent .= '<tfoot><tr><td colspan="' . $colspan . '" class="order_total_data text-right">';
            if ($this->ms['MODULES']['ORDER_EDIT'] and $settings['enable_edit_orders_details']) {
                $iso_customer = mslib_fe::getCountryByName($orders['billing_country']);
                $iso_customer['country'] = $iso_customer['cn_short_en'];
                //
                $payment_method = mslib_fe::getPaymentMethod($orders['payment_method'], 'p.code', $iso_customer['cn_iso_nr']);
                $shipping_method = mslib_fe::getShippingMethod($orders['shipping_method'], 's.code', $iso_customer['cn_iso_nr']);
                //
                if ($iso_customer['cn_iso_nr'] > 0) {
                    $payment_tax_ruleset = mslib_fe::taxRuleSet($payment_method['tax_id'], 0, $iso_customer['cn_iso_nr'], 0);
                    $shipping_tax_ruleset = mslib_fe::taxRuleSet($shipping_method['tax_id'], 0, $iso_customer['cn_iso_nr'], 0);
                    if (!$payment_tax_ruleset) {
                        $payment_method['tax_id'] = 0;
                    }
                    if (!$shipping_tax_ruleset) {
                        $shipping_method['tax_id'] = 0;
                    }
                }
                if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) {
                    $shipping_costs = '<div class="input-group pull-right" style="width:140px;">
						<span class="input-group-addon">' . mslib_fe::currency() . '</span>
						<input name="tx_multishop_pi1[shipping_method_costs]" id="shipping_method_costs" type="text" class="form-control text-right priceInputDisplay" value="' . number_format($orders['shipping_method_costs'] + $orders_tax_data['shipping_tax'], 4, $this->ms['MODULES']['CUSTOMER_CURRENCY_ARRAY']['cu_decimal_point'], '') . '" class="align_right" />