Results 1 to 9 of 9
  1. #1
    Join Date
    May 2010
    Location
    Arkansas
    Posts
    33
    Plugin Contributions
    0

    Default Building Shipping Module Question

    Could someone point me to where it decides what shipping modules to display? I need to setup a conditional statement that only displays an option when a database field is equal to "XXXX" or something else....you get the picture.

    Anyway, where does it actually make this decision? I've found a couple variables that seem to decide what shipping methods are allowed, I am just not seeing where it actually constructs this var. Also, it seems to only hold the selected module, I need to catch it before then.

    And since rereading that, now I'm confused, I hope someone can decipher what I'm trying to ask. Basically, where the heck does zen cart say, "oh yea use this and that, but not those" as far as shipping goes.

    Thanks!

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Building Shipping Module Question

    Let's say you want to test if any Products in the Cart are from master_categories_id 10 or 12 ...

    If some exist, you want to turn OFF the Flat Rate flat shipping module ...

    Add the code in RED to the file:
    /includes/modules/shipping/flat.php

    Code:
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
          }
    
    // bof: add extra control
      // do not run unless in catalog
      if (!IS_ADMIN_FLAG) {
        // check the count of a specific field
        $chk_cat = 0;
        // check how many Products are in the cart for master_categories_id 10 and 12
        $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','10');
        $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','12');
        // if any are found turn off the shipping module
        if ($chk_cat > 0) {
          $this->enabled = false;
        }
      }
    // eof: add extra control
    
          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) {
    There are lots of ways to customize shipping modules ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    May 2010
    Location
    Arkansas
    Posts
    33
    Plugin Contributions
    0

    Default Re: Building Shipping Module Question

    OK, so I would need to add it to all shipping modules I need to include in this. Basically I am setting up so UPS shipping shows if a drop ship item is in the cart, and USPS shows if it is strictly items from the clients shop. But neither can show if the other is showing.

    Thanks!

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Building Shipping Module Question

    Yes, you can use the function in_cart_check in the shopping_cart class to test any field in the products table and see if any are in the cart ...

    What are you going to do if you have 1 Product that uses UPS and 1 Product that uses USPS?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    May 2010
    Location
    Arkansas
    Posts
    33
    Plugin Contributions
    0

    Default Re: Building Shipping Module Question

    I don't have a good answer for that, but since the UPS rates are higher and most of the drop shippers use UPS, I figured on having it as a flag type variable, so that once it is flagged, it only shows UPS for the order, and disregards the items that would ship through USPS normally.

    It isn't perfect, but the client is losing cash on almost every drop ship item, so this is what we have for now. He doesn't want to invest the time to build a module that breaks it all down and deals with all the eventualities.

  6. #6
    Join Date
    May 2010
    Location
    Arkansas
    Posts
    33
    Plugin Contributions
    0

    Default Re: Building Shipping Module Question

    One more quick question, is there a way to check a negative with that function? Or something built in that does this? Basically need something like this
    PHP Code:
    $_SESSION['cart']->in_cart_check("some_column","!=0"); 

  7. #7
    Join Date
    May 2010
    Location
    Arkansas
    Posts
    33
    Plugin Contributions
    0

    Default Re: Building Shipping Module Question

    Changed the in_cart_check to accept a comparison variable too. Here is the edit if anyone is interested.

    /zen_cart/includes/classes/shopping_cart.php

    edit beginning of function to read this
    PHP Code:

      
    function in_cart_check($check_what$check_value='1',[B$operator "=="[/B]) { 
    Then edited further down in the function to handle what I needed it to, for more operators, more cases are needed.

    PHP Code:
          if($operator != "=="){
            switch(
    $operator){
                case 
    ">":
                  if (
    $product_check->fields['check_it'] > $check_value) {
                    
    $in_cart_check_qty += $this->contents[$products_id]['qty'];
                  }
                break;
                case 
    "<":
                  if (
    $product_check->fields['check_it'] < $check_value) {
                    
    $in_cart_check_qty += $this->contents[$products_id]['qty'];
                  }
                   break;
            }
          } else {
              if (
    $product_check->fields['check_it'] == $check_value) {
                
    $in_cart_check_qty += $this->contents[$products_id]['qty'];
              }
          } 
    And it needs to replace this

    PHP Code:
              if ($product_check->fields['check_it'] == $check_value) {
                
    $in_cart_check_qty += $this->contents[$products_id]['qty'];
              } 
    If there is a better way to do this, let me know. Now, I just run the check you suggested, change the operator to greater than, and I'm good to go.

    Thanks for the help!

  8. #8
    Join Date
    May 2010
    Location
    Arkansas
    Posts
    33
    Plugin Contributions
    0

    Default Re: Building Shipping Module Question

    and in the first block take out the bold bbcode tags....

  9. #9
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Building Shipping Module Question

    Quote Originally Posted by skrillnet View Post
    If there is a better way to do this, let me know.
    Nice code!

    Cheers
    Rod

 

 

Similar Threads

  1. Shipping Module Programming Question about weight and free shipping
    By voltar in forum Built-in Shipping and Payment Modules
    Replies: 59
    Last Post: 18 Nov 2011, 10:29 PM
  2. Installation and building question
    By MattS in forum Installing on a Windows Server
    Replies: 3
    Last Post: 15 Feb 2010, 01:12 AM
  3. Building a custom module
    By Baiazid in forum Addon Shipping Modules
    Replies: 3
    Last Post: 12 Jun 2009, 04:43 AM
  4. Help building/cloning Shipping module for API
    By danstever in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 29 Feb 2008, 04:17 PM
  5. Simple question about building a new template
    By Shade in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 12 Mar 2007, 04:53 PM

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