Results 1 to 3 of 3
  1. #1
    Join Date
    May 2014
    Location
    Oakdale, California, United States
    Posts
    31
    Plugin Contributions
    1

    Default Direct shipping for out of stock orders

    Is it possible to ship by whether products are in stock or not? I have a client that wants an order of in stock items to ship on a table, then out of stock or mixed orders to ship direct from the manufacturer, using the ups xml. I'm not sure if there is already something out there that does this or if I will have to write it myself, but any pointers would be appreciated.

  2. #2
    Join Date
    May 2014
    Location
    Oakdale, California, United States
    Posts
    31
    Plugin Contributions
    1

    Default Re: Direct shipping for out of stock orders

    My guess is that I would create a loop on checkout that would go through all the products, if one is out of stock, I set the shipping to UPS XML. Otherwise ship using table method.

  3. #3
    Join Date
    May 2014
    Location
    Oakdale, California, United States
    Posts
    31
    Plugin Contributions
    1

    Default Re: Direct shipping for out of stock orders

    and, problem solved. In the /includes/modules/pages/checkout_shipping/header_php.php if you've already installed Stock by Attributes there is already an in-stock loop. just a copy paste without the condition will do it, Search for:
    Code:
    // Stock Check
     if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
        $products = $_SESSION['cart']->get_products();
        for ($i=0, $n=sizeof($products); $i<$n; $i++) {
    
            // START "Stock by Attributes"
            // Added to allow individual stock of different attributes
            unset($attributes);
            if(is_array($products[$i]['attributes'])){
                $attributes = $products[$i]['attributes'];
            } 
            else{
                  $attributes = null;
            }
        
            if(!empty($attributes)){
                if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'], $attributes)) {
                    zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
                    break;
                }
            }
            else{
                  if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
                      zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
                      break;
                  }
            }
         }   
        // END "Stock by Attributes"
    Then add BEFORE it:
    Code:
    //In Stock Shipping Check
    $in_stock_flag = true;
        $products = $_SESSION['cart']->get_products();
        for ($i=0, $n=sizeof($products); $i<$n; $i++) {
    
        // START "Stock by Attributes"
        // Added to allow individual stock of different attributes
          unset($attributes);
          if(is_array($products[$i]['attributes'])){
          $attributes = $products[$i]['attributes'];
          } 
          else{
              $attributes = null;
          }
      
        if(!empty($attributes)){
            if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'], $attributes)) {
              $in_stock_flag = false;
              break;
            }
          }
          else{
              if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
                $in_stock_flag = false;
                break;
              }
          }
      }   
    // END in stock shipping
    Then search for where the shipping modules are loaded:
    Code:
    // load all enabled shipping modules
      require(DIR_WS_CLASSES . 'shipping.php');
      $shipping_modules = new shipping;
    and insert your specific logic immediately AFTER:
    Code:
    if (!in_stock_flag){
      $shipping_modules->modules = array("upsxml.php");
    }
    else {
      if ($_SESSION['customer_whole'] && $_SESSION['customer_whole'] != '0' ) {
        $shipping_modules->modules = array("wholesaletable.php");
      } else {
        $shipping_modules->modules = array("table.php");
      }
    }

 

 

Similar Threads

  1. Replies: 5
    Last Post: 3 Aug 2011, 08:15 AM
  2. Stock by Attribute setup and product has stock when added to card says out of stock
    By kwrosenzweig in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 9 Jun 2011, 06:18 PM
  3. Using weight for shipping amounts - calculates wrong shipping when out of stock
    By trev-h in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 14 Apr 2009, 09:57 PM
  4. Handling Orders which include items out of stock
    By guyhancock in forum General Questions
    Replies: 4
    Last Post: 12 Dec 2008, 06:16 PM
  5. Hide stock count and not check for out of stock
    By microbe in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 12 Feb 2008, 12:08 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR