$load_mappings_order = array();
$load_mappings_order[] = 'products';
$load_mappings_order[] = 'customers_groups';
$load_mappings_order[] = 'customers';
foreach ($load_mappings_order as $mapping) {
    switch ($mapping) {
        case 'products':
            if ($this->ms['MODULES']['PRODUCT_EDIT_METHOD_FILTER']) {
                $pids = array();
                foreach ($cart['products'] as $key => $array) {
                    if (is_numeric($array['products_id'])) {
                        $pids[] = $array['products_id'];
                    }
                }
                if (count($pids)) {
                    $mapped_shipping_methods_product = mslib_fe::getProductMappedMethods($pids, 'shipping', $tmp_countries['cn_iso_nr']);
                }
            }
            break;
        case 'customers_groups':
            if (mslib_fe::loggedin() && $this->ms['MODULES']['GROUP_EDIT_METHOD_FILTER']) {
                $user_groups = array();
                $user_groups = explode(',', $GLOBALS['TSFE']->fe_user->user['usergroup']);
                if (count($user_groups)) {
                    $mapped_shipping_methods_group = mslib_fe::getCustomerGroupMappedMethods($user_groups, 'shipping', $tmp_countries['cn_iso_nr']);
                }
            }
            break;
        case 'customers':
            if (mslib_fe::loggedin() && $this->ms['MODULES']['CUSTOMER_EDIT_METHOD_FILTER']) {
                $user_id = array();
Beispiel #2
0
 $load_mappings_order[] = 'customers';
 foreach ($load_mappings_order as $mapping) {
     switch ($mapping) {
         case 'products':
             if ($this->ms['MODULES']['PRODUCT_EDIT_METHOD_FILTER']) {
                 $payment_methods = array();
                 $shipping_methods = array();
                 $pids = array();
                 foreach ($cart['products'] as $key => $array) {
                     if (is_numeric($array['products_id'])) {
                         $pids[] = $array['products_id'];
                     }
                 }
                 if (count($pids)) {
                     $payment_methods_product = mslib_fe::getProductMappedMethods($pids, 'payment', $user_country);
                     $shipping_methods_product = mslib_fe::getProductMappedMethods($pids, 'shipping');
                 }
             }
             break;
         case 'customers_groups':
             if ($this->ms['MODULES']['GROUP_EDIT_METHOD_FILTER']) {
                 $payment_methods = array();
                 $shipping_methods = array();
                 $tmp_user_groups = explode(',', $GLOBALS['TSFE']->fe_user->user['usergroup']);
                 $user_groups = array();
                 foreach ($tmp_user_groups as $tmp_user_group) {
                     if ($tmp_user_group > 0) {
                         $user_groups[] = $tmp_user_group;
                     }
                 }
                 if (count($user_groups)) {
Beispiel #3
0
 public function getProductShippingCostsOverview($countries_id, $products_id, $products_quantity = 1)
 {
     if (!is_numeric($countries_id)) {
         return false;
     }
     if (!is_numeric($products_id)) {
         return false;
     }
     $product_data = mslib_fe::getProduct($products_id);
     if (!is_numeric($products_quantity)) {
         $products_quantity = 1;
         if ($product_data['minimum_quantity'] > 0) {
             $products_quantity = $product_data['minimum_quantity'];
         }
     }
     $product_mappings = mslib_fe::getProductMappedMethods(array($products_id), 'shipping', $countries_id);
     $shipping_method_data = mslib_fe::loadShippingMethods(0, $countries_id, true, true);
     if (!count($product_mappings)) {
         $product_mappings = $shipping_method_data;
     }
     $shipping_methods = array();
     foreach ($shipping_method_data as $load_shipping_method) {
         $shipping_method_id = $load_shipping_method['id'];
         $str3 = $GLOBALS['TYPO3_DB']->SELECTquery('sm.shipping_costs_type, sm.handling_costs, c.override_shippingcosts, c.price, c.zone_id', 'tx_multishop_shipping_methods sm, tx_multishop_shipping_methods_costs c, tx_multishop_countries_to_zones c2z', 'c.shipping_method_id=\'' . $shipping_method_id . '\' and (sm.page_uid=0 or sm.page_uid=\'' . $this->shop_pid . '\') and sm.id=c.shipping_method_id and c.zone_id=c2z.zone_id 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);
             if (isset($product_mappings[$shipping_method['code']])) {
                 if ($row3['shipping_costs_type'] == 'weight') {
                     $total_weight = $product_data['products_weight'] * $products_quantity;
                     $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;
                 } elseif ($row3['shipping_costs_type'] == 'quantity') {
                     $total_quantity = $products_quantity;
                     $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;
                 } else {
                     $shipping_cost = $row3['price'];
                 }
                 $subtotal = $product_data['final_price'];
                 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];
                                         continue;
                                     } else {
                                         $shipping_cost = $old_shipping_costs;
                                     }
                                 }
                                 $count++;
                             }
                         }
                     }
                 }
                 // custom code to change the shipping costs based on cart amount
                 if (strstr($shipping_cost, ",")) {
                     $steps = explode(",", $shipping_cost);
                     // calculate total costs
                     $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];
                                 } else {
                                     $shipping_cost = $split[0];
                                     continue;
                                 }
                             }
                             if ($subtotal > $split[0] and isset($split[1])) {
                                 $shipping_cost = $split[1];
                                 continue;
                             }
                         }
                         $count++;
                     }
                 }
                 // custom code to change the shipping costs based on cart amount
                 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'];
                     $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;
                         $subtotal = $product_data['final_price'];
                         if ($subtotal) {
                             $handling_cost = $subtotal / 100 * $tmp_handling_cost;
                         }
                     }
                     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_methods[$shipping_method['code']]['shipping_costs'] = $shipping_cost;
                 $shipping_methods[$shipping_method['code']]['shipping_costs_including_vat'] = $shipping_cost + $shipping_tax;
                 $unserialize_sm = unserialize($row3['vars']);
                 $shipping_methods[$shipping_method['code']]['deliver_by'] = $shipping_method['name'];
                 //$unserialize_sm['name'][0];
                 $shipping_methods[$shipping_method['code']]['product_name'] = $product_data['products_name'];
             }
         }
     }
     if (count($shipping_methods)) {
         return $shipping_methods;
     }
     return false;
 }
Beispiel #4
0
     break;
 case 'get_shoppingcart_shippingmethod_overview':
     $return_data = array();
     $country_cn_iso_nr = $this->post['tx_multishop_pi1']['country_id'];
     //
     //$cart=$GLOBALS['TSFE']->fe_user->getKey('ses', $this->cart_page_uid);
     require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'pi1/classes/class.tx_mslib_cart.php';
     $mslib_cart = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_mslib_cart');
     $mslib_cart->init($this);
     $cart = $mslib_cart->getCart();
     $products = $cart['products'];
     $pids = array();
     foreach ($products as $product) {
         $pids[] = $product['products_id'];
     }
     $product_mappings = mslib_fe::getProductMappedMethods($pids, 'shipping', $country_cn_iso_nr);
     //
     $shipping_methods = mslib_fe::loadShippingMethods(0, $country_cn_iso_nr, true, true);
     if (!count($product_mappings)) {
         $product_mappings = $shipping_methods;
     }
     $return_data['shipping_methods'] = array();
     foreach ($shipping_methods as $shipping_method) {
         if (isset($product_mappings[$shipping_method['code']])) {
             $return_data['shipping_methods'][] = $shipping_method;
         }
     }
     echo json_encode($return_data);
     exit;
     break;
 case 'get_shoppingcart_shippingcost_overview':
$load_mappings_order = array();
$load_mappings_order[] = 'products';
$load_mappings_order[] = 'customers_groups';
$load_mappings_order[] = 'customers';
foreach ($load_mappings_order as $mapping) {
    switch ($mapping) {
        case 'products':
            if ($this->ms['MODULES']['PRODUCT_EDIT_METHOD_FILTER']) {
                $pids = array();
                foreach ($cart['products'] as $key => $array) {
                    if (is_numeric($array['products_id'])) {
                        $pids[] = $array['products_id'];
                    }
                }
                if (count($pids)) {
                    $payment_methods_product = mslib_fe::getProductMappedMethods($pids, 'payment', $countries_id);
                }
            }
            break;
        case 'customers_groups':
            if (mslib_fe::loggedin() && $this->ms['MODULES']['GROUP_EDIT_METHOD_FILTER']) {
                $user_groups = array();
                $user_groups = explode(',', $GLOBALS['TSFE']->fe_user->user['usergroup']);
                if (count($user_groups)) {
                    $payment_methods_group = mslib_fe::getCustomerGroupMappedMethods($user_groups, 'payment', $countries_id);
                }
            }
            break;
        case 'customers':
            if (mslib_fe::loggedin() && $this->ms['MODULES']['CUSTOMER_EDIT_METHOD_FILTER']) {
                $user_id = array();