Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Warning: split() [function.split]: Invalid preceding regular expression in


blr044

Recommended Posts

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.

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...