mightyx Posted May 6, 2010 Share Posted May 6, 2010 I want offer express shipping in my shop, but the problem is, that nor all products are in stock and can be delivered by express. So my thought was, to build a shipping module, that checks if the contents of the cart has only products in it, that are in stock. Then the express shipping module can be enabled in checkout_shipping.php. It tried this in the flat.php module but it doesn't work... Can someone help me? class flat { var $code, $title, $description, $icon, $enabled; // class constructor function flat() { global $order, $cart; $this->code = 'flat'; $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE; $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false); $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']); if (tep_not_null($stock_check)) { $any_out_of_stock = 1; } if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) && ($any_out_of_stock = 1) ) { Quote Link to comment Share on other sites More sharing options...
web-project Posted May 6, 2010 Share Posted May 6, 2010 if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) && ($any_out_of_stock = 1) ) { it should be if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) && ($any_out_of_stock == 1) ) { you see the difference? $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']); if (tep_not_null($stock_check)) { $any_out_of_stock = 1; } do you have any sql queries for above code, as you copied from somewhere else this code, without SQL query. Quote Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here! 8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself. Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues. Any issues with oscommerce, I am here to help you. Link to comment Share on other sites More sharing options...
mightyx Posted May 7, 2010 Author Share Posted May 7, 2010 I copied it from shopping_cart.php and I have no SQL queries in the shipping module. What should I select from SQL for that query? Quote Link to comment Share on other sites More sharing options...
mightyx Posted May 7, 2010 Author Share Posted May 7, 2010 (edited) So here's my actual code for the "express" Shipping module. function get_products() { global $languages_id; if (!is_array($this->contents)) return false; $products_array = array(); reset($this->contents); while (list($products_id, ) = each($this->contents)) { $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); if ($products = tep_db_fetch_array($products_query)) { $prid = $products['products_id']; $products_price = $products['products_price']; $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } //Impulse Item by jfj $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS_CHECKOUT . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows ($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } //Impulse Item by jfj $attribute_code_array = array(); if (is_array($this->contents[$products_id]['attributes'])) { while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_code_query = tep_db_query("select code_suffix, suffix_sort_order from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_code = tep_db_fetch_array($attribute_code_query); if (tep_not_null($attribute_code['code_suffix'])) { $attribute_code_array[(int)$attribute_code['suffix_sort_order']] = $attribute_code['code_suffix']; } } $separator = ''; if (count($attribute_code_array) > 1) { $separator = '-'; } elseif (count($attribute_code_array) == 1) { $separator = '-'; } $products_code = $products['products_model'] . $separator . implode("/", $attribute_code_array); } else { $products_code = $products['products_model']; } $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'code' => $products_code, 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '')); } } return $products_array; } Edited May 7, 2010 by mightyx Quote Link to comment Share on other sites More sharing options...
mightyx Posted July 8, 2010 Author Share Posted July 8, 2010 Anyone with a solution for this module? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.