blr044 Posted July 21, 2010 Share Posted July 21, 2010 I hope I'm at the correct location for exclude products for free shipping. By searching Google, I was not able to find a solution to my issue. Because few of my vendors, some products is shipped free. So to pass this onto my customers, I looked for an contribution that would do such an task. But when at checkout_shipping.php I receive the following error message. Warning: split() [function.split]: Invalid preceding regular expression in /xxxx/xxxx/xxxxxxxx/xxxxx/xxx/includes/classes/order.php on line 327 Warning: split() [function.split]: Invalid preceding regular expression in /xxxx/xxxx/xxxxxxxx/xxxxx/xxx/includes/classes/order.php on line 327 Warning: split() [function.split]: Invalid preceding regular expression in /xxxx/xxxx/xxxxxxxx/xxxxx/xxx/includes/classes/order.php on line 327 The code that I added to catalog/includes/classes/order.php is below to which this error refers to: Lines 323 thru 335: ///////// BOF exclude products from free shipping total V 1.0 ///////// $excluded_products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where exclude_free_shipping = 1 "); while ($excluded_products = tep_db_fetch_array($excluded_products_query)) { $string_id = $products[$i]['id'] ; //something ugly like 71{1}14, we need 71 $string_idArray = split('{',$string_id); //the first in our array will be the products_id even if it has attributes if($string_idArray[0] == $excluded_products['products_id']) { $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']; $this->info['subtotal_excluded'] += $shown_price; } } ///////// EOF exclude products from free shipping total V 1.0 ///////// Also I added three items to cart for testing purposes. Two products which should shipping/handling and the third is shipped free. But at checkout, all three is shipped free. Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted July 21, 2010 Share Posted July 21, 2010 osC has a function for that in includes/functions/general.php: // Return a product ID from a product ID with attributes function tep_get_prid($uprid) { etc. So no point in reinventing that functionality (it uses explode instead of split though). Quote Link to comment Share on other sites More sharing options...
blr044 Posted July 21, 2010 Author Share Posted July 21, 2010 osC has a function for that in includes/functions/general.php: // Return a product ID from a product ID with attributes function tep_get_prid($uprid) { etc. So no point in reinventing that functionality (it uses explode instead of split though). Thanks. But not sure if I did this right. I went into order.php and comment out lines 323 thru 335. Okay, error messages have vanished. But in Order Total Modules, I have free shipping set at true. If only item in cart is shipped free, it is fine. But if I add items for which will be charged s/h, the total shipping still shows as $0 instead of correct amount cost. Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted July 21, 2010 Share Posted July 21, 2010 But not sure if I did this right. I went into order.php and comment out lines 323 thru 335. I don't understand why you did that. I only wanted to point out that removing attributes from a products_id is done in a function that is present in osC so that you could rewrite that part with split to: while ($excluded_products = tep_db_fetch_array($excluded_products_query)) { // $string_id = $products[$i]['id'] ; //something ugly like 71{1}14, we need 71 $string_id = tep_get_prid($products[$i]['id']); // remove attributes if ($string_id == $excluded_products['products_id']) { $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']; $this->info['subtotal_excluded'] += $shown_price; } } If this is in a loop that goes over all products in the shopping cart and does that query again and again for every product in the cart then that is is a ..... let's say inefficient.... way of doing things. 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.