Exemplo n.º 1
0
         }
         // end for loop
     }
     zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
     break;
     // eof delete new
     /////////////////////////////////
     // @@TODO where is delete_product_confirm
 // eof delete new
 /////////////////////////////////
 // @@TODO where is delete_product_confirm
 case 'move_category_confirm':
     if (isset($_POST['categories_id']) && $_POST['categories_id'] != $_POST['move_to_category_id']) {
         $categories_id = zen_db_prepare_input($_POST['categories_id']);
         $new_parent_id = zen_db_prepare_input($_POST['move_to_category_id']);
         $path = explode('_', zen_get_generated_category_path_ids($new_parent_id));
         if (in_array($categories_id, $path)) {
             $messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error');
             zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
         } else {
             $sql = "select count(*) as count from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . (int) $new_parent_id . "'";
             $zc_count_products = $db->Execute($sql);
             if ($zc_count_products->fields['count'] > 0) {
                 $messageStack->add_session(ERROR_CATEGORY_HAS_PRODUCTS, 'error');
             } else {
                 $messageStack->add_session(SUCCESS_CATEGORY_MOVED, 'success');
             }
             $db->Execute("update " . TABLE_CATEGORIES . "\n                            set parent_id = '" . (int) $new_parent_id . "', last_modified = now()\n                            where categories_id = '" . (int) $categories_id . "'");
             // fix here - if this is a category with subcats it needs to know to loop through
             // reset all products_price_sorter for moved category products
             $reset_price_sorter = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . (int) $categories_id . "'");
 }
 // if ($ep_dltype ...
 // CATEGORIES EXPORT
 // chadd - 12-13-2010 - logic change. $max_categories no longer required. better to loop back to root category and
 // concatenate the entire categories path into one string with $category_delimiter for separater.
 if ($ep_dltype == 'full' || $ep_dltype == 'category') {
     // chadd - 12-02-2010 fixed error: missing parenthesis
     // NEW While-loop for unlimited category depth
     $category_delimiter = "^";
     $thecategory_id = $row['v_categories_id'];
     // starting category_id
     if ($ep_dltype == 'full' && EASYPOPULATE_4_CONFIG_EXPORT_URI != '0') {
         $sql_type = "SELECT type_handler FROM " . TABLE_PRODUCT_TYPES . " WHERE type_id = " . (int) zen_get_products_type($row['v_products_id']);
         $sql_typename = $db->Execute($sql_type);
         //        $row['v_html_uri'] = zen_href_link(FILENAME_DEFAULT, 'main_page=' . $sql_typename->fields['type_handler'] . '_info&cPath=' . zen_get_generated_category_path_ids($row['v_master_categories_id']) . '&products_id=' . $row['v_products_id'],'NONSSL', false, true, false, true); //This generates an admin folder like link/reference not a catalog version.
         $row['v_html_uri'] = zen_catalog_href_link($sql_typename->fields['type_handler'] . '_info', 'cPath=' . zen_get_generated_category_path_ids($row['v_master_categories_id']) . '&products_id=' . $row['v_products_id'], 'NONSSL');
         //zen_catalog_href_link($page = '', $parameters = '', $connection = 'NONSSL')        //FILENAME_DEFAULT . '?main_page=' . zen_get_products_type($row['products_id'])
         //function zen_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true, $static = false, $use_dir_ws_catalog = true)
     }
     // $fullcategory = array(); // this will have the entire category path separated by $category_delimiter
     // if parent_id is not null ('0'), then follow it up.
     while (!empty($thecategory_id)) {
         // mult-lingual categories start - for each language, get category description and name
         $sql2 = 'SELECT * FROM ' . TABLE_CATEGORIES_DESCRIPTION . ' WHERE categories_id = ' . $thecategory_id . ' ORDER BY language_id';
         $result2 = ep_4_query($sql2);
         while ($row2 = $ep_uses_mysqli ? mysqli_fetch_array($result2) : mysql_fetch_array($result2)) {
             $lid = $row2['language_id'];
             $row['v_categories_name_' . $lid] = $row2['categories_name'] . $category_delimiter . $row['v_categories_name_' . $lid];
         }
         // look for parent categories ID
         $sql3 = 'SELECT parent_id FROM ' . TABLE_CATEGORIES . ' WHERE categories_id = ' . $thecategory_id;
Exemplo n.º 3
0
 function _retrieve_categories_ratio($categories_id)
 {
     global $db;
     // we check if the ratio for this category is already retrieved before, then we dont have to query the db again
     if (isset($this->categories_ratio["{$categories_id}"])) {
         return $this->categories_ratio["{$categories_id}"];
     }
     $cPath = zen_get_generated_category_path_ids($categories_id);
     $categories = explode('_', $cPath);
     $match = false;
     foreach ($categories as $category_id) {
         $sql = 'SELECT ratio FROM ' . TABLE_SC_CATEGORIES_RATIO . ' WHERE categories_id=' . $category_id . ' LIMIT 1';
         $ratio = $db->Execute($sql);
         if ($ratio->RecordCount() == 1) {
             $this->categories_ratio["{$categories_id}"] = $ratio->fields['ratio'];
             $match = true;
             return $ratio->fields['ratio'];
         }
     }
     if (!$match) {
         return 'false';
     }
 }
Exemplo n.º 4
0
 function get_order_total()
 {
     global $order;
     $order_total = $order->info['total'];
     //echo($order_total . '<br />');
     if (MODULE_ORDER_TOTAL_SC_EXCLUDE_CATEGORIES == 'true') {
         // go through every product and any that are within a category that has a 0 ratio, subtract the products total from the order total
         $products = $_SESSION['cart']->get_products();
         foreach ($products as $product) {
             $subtract = false;
             // first check products ratio
             if ($this->_retrieve_products_ratio($product['id']) != 'false' && $this->_retrieve_products_ratio($product['id']) == 0) {
                 $subtract = true;
                 // set to true to subtract later
             } elseif ($this->_retrieve_products_ratio($product['id']) == 'false') {
                 // check category instead
                 $categories_id = zen_get_products_category_id($product['id']);
                 $cPath = zen_get_generated_category_path_ids($categories_id);
                 $categories = explode('_', $cPath);
                 foreach ($categories as $category_id) {
                     if ($this->_retrieve_categories_ratio($category_id) != 'false' && $this->_retrieve_categories_ratio($category_id) == 0) {
                         $subtract = true;
                         break;
                         // starts with lowest most category, so break if anything is found
                     }
                 }
             }
             if ($subtract) {
                 $price = $product['quantity'] * $product['final_price'];
                 $order_total -= $price;
             }
         }
     }
     if (MODULE_ORDER_TOTAL_SC_EXCLUDE_SHIPPING == 'true') {
         // shipping excluded
         $order_total -= $order->info['shipping_cost'];
     }
     //die($order_total);
     return $order_total;
 }