Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Can anyone help me wih this?

 

I want a shipping module that will only be available in checkout_shipping.php if all items in the cart have quantity of more than 1 in stock. The reason for this is that it will be a next day shipping option which will only be available for in-stock items.

 

For me it will be best to use a modified table rate module. I know I need to put the clause inside the function quote($method = '') { } tags in the same way that the zones module gives this error:

 

if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_ZONES_INVALID_ZONE;

 

I just don't know how to query the items in the cart to make sure they all have products_quantity greater than 1. If anyone can help I'd appreciate it.

 

Tim

Posted

Well I've done some messing around and got something to work. In the shipping module I've added the following lines at the end of the quotes function:

      $out_stock = $cart->all_in_stock();
     if ($out_stock > 0) $this->quotes['error'] = MODULE_SHIPPING_NEXTDAY_NO_STOCK;

 

and added this function into classes/shopping_cart.php

    function all_in_stock() { //Check if all cart contents are in stock
     $all_in_stock = 0;
     if (is_array($this->contents)) {
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
         $stock_quantity_query = tep_db_query("select products_id, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
         $stock_quantity = tep_db_fetch_array($stock_quantity_query);
         if($this->get_quantity($products_id) > $stock_quantity['products_quantity']) {
     $all_in_stock += 1;
   }
       }
     }
     return $all_in_stock;
   }

 

This works OK but it doesn't work as a drop-in shipping module as you need to change a core OSC file. Does anyone know how transfer the function into the shipping module and change all the $this->contents references to still pick up cart contents?

 

Again, any help is appreciated.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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