Page 5 of 10 FirstFirst ... 34567 ... LastLast
Results 41 to 50 of 99
  1. #41
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Flat Rate Shipping - Table Rates - Duplicate for Category Specific Items?

    That's cause when I made that cute little function to grab info from the shopping cart it did not occur to me to make an ambiguous function to do that ...

    And, as you want a bazillion possible categories_id from Linked products to be checked now there are while loops and other fun things to check out and some ways to approach this are doggie and others are fast ...

    Hense ... da think ... think ... think ... for a few ... hopefully minutes rather than days ...
    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!

  2. #42
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Flat Rate Shipping - Table Rates - Duplicate for Category Specific Items?

    I like how you think like a woman of action, but act like a woman of thought

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

    Default Re: Flat Rate Shipping - Table Rates - Duplicate for Category Specific Items?

    Okay ... hopefully this covers all the bases so that you can determine what you really want ...

    Code:
    // bof: only show if all Products are from master_categories_id, individual products_id and Linked Categories
      if (!IS_ADMIN_FLAG) {
        // check the count of a specific field
        $chk_catAll = 0;
        $chk_cats = 0;
        $chk_catAll = $_SESSION['cart']->count_contents();
        // check how many Products are in the cart for master_categories_id 409, 7, 103, 104, 12
        $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','409');
        $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','7');
        $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','103');
        $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','104');
        $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','12');
    echo 'Products master_categories_id Found: ' . $chk_cats . '<br>';
    
        // check individual products_id 168, 169, 172
        $chk_products_found = 0;
        $chk_products = $_SESSION['cart']->get_products();
        for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
          if ( in_array((int)$chk_products[$i]['id'], array(168, 169, 172)) ) {
            $chk_products_found += $chk_products[$i]['quantity'];
          }
        }
    echo 'Products Individual Found: ' . $chk_products_found . '<br>';
    
        // check Products from Linked Categories 5, 10, 22
        $chk_linked = $db->Execute("SELECT distinct products_id FROM products_to_categories WHERE categories_id IN (5, 10, 22)");
        while(!$chk_linked->EOF) {
          $selected_products_check .= $chk_linked->fields['products_id'];
          $chk_linked->MoveNext();
          if (!$chk_linked->EOF) {
            $selected_products_check .= ',';
          }
        }
        $selected_products = explode(',', $selected_products_check);
        // check cart contents for linked products
        $chk_products_linked = $chk_products;
        $chk_products_found_linked = 0;
        for ($i=0, $n=sizeof($chk_products_linked); $i<$n; $i++) {
          if ( in_array((int)$chk_products_linked[$i]['id'], $selected_products) ) {
            $chk_products_found_linked += $chk_products_linked[$i]['quantity'];
          }
        }
    echo 'Products Linked Found: ' . $chk_products_found_linked . '<br>';
    
        // if any are found turn off the shipping module
        if (($chk_cats + $chk_products_found + $chk_products_found_linked) != $chk_catAll) {
          $this->enabled = false;
        }
      }
    // eof: only show if all Products are from master_categories_id, individual products_id and Linked Categories
    So you have 3 methods here:
    1 Check by master_categories_id

    2 Check by individual products_id

    3 Check by Products that are linked to categories

    NOTE: the echos are there so you can see the results of each check ...

    NOTE: this does NOT test that you did not combine Products in each test multiple times, meaning if you have Products that are in the master_categories_id check that are also in the Linked Categories test and/or Individual Product test then they will be counted multiple times ...

    So, I would need to work out a "cleaner" to prevent multiple counts of the 3 test, if you think that may happen ...

    If you think that may happen, fess up now ...
    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!

  4. #44
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Flat Rate Shipping - Table Rates - Duplicate for Category Specific Items?

    Thank you for doing all that Ajeh, it looks really, really, really complicated :) I've been creating a play-site while you were thinking:

    http://www.silkblooms.co.uk/test/

    I think I will put the mod on there and give it a whirl. I'm not sure what combo could potentially break things, so I'll try a few. Doe it matter if the products are counted multiple times? Counted by what? The cart?

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

    Default Re: Flat Rate Shipping - Table Rates - Duplicate for Category Specific Items?

    Smarter code ...

    1 Test for Categories and 1 test for Individual Products:
    Code:
    // bof: only show if all Products are from individual products_id and Master/Linked Categories
      if (!IS_ADMIN_FLAG) {
        // check individual products_id 168, 169, 172
        $chk_products_found = 0;
        $chk_products = $_SESSION['cart']->get_products();
        for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
          if ( in_array((int)$chk_products[$i]['id'], array(168, 169, 172)) ) {
            $chk_products_found += $chk_products[$i]['quantity'];
          }
        }
    echo 'Products Individual Found: ' . $chk_products_found . '<br>';
    
        // check Products from Linked/Master Categories 5, 10, 12, 22, 64
        $chk_linked = $db->Execute("SELECT distinct products_id FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE categories_id IN (5, 10, 12, 22, 64)");
        while(!$chk_linked->EOF) {
          $selected_products_check .= $chk_linked->fields['products_id'];
          $chk_linked->MoveNext();
          if (!$chk_linked->EOF) {
            $selected_products_check .= ',';
          }
        }
        $selected_products = explode(',', $selected_products_check);
        // check cart contents for linked products
        $chk_products_linked = $chk_products;
        $chk_products_found_linked = 0;
        for ($i=0, $n=sizeof($chk_products_linked); $i<$n; $i++) {
          if ( in_array((int)$chk_products_linked[$i]['id'], $selected_products) ) {
            $chk_products_found_linked += $chk_products_linked[$i]['quantity'];
          }
        }
    echo 'Products Master/Linked Found: ' . $chk_products_found_linked . '<br>';
    
        $chk_cat_total = ($chk_products_found + $chk_products_found_linked);
    
        // if any Products are found and does not match ALL products in cart turn off the shipping module
        if (($chk_cat_total) != $chk_catAll) {
          $this->enabled = false;
        }
      }
    // eof: only show if all Products are from individual products_id and Master/Linked Categories
    At this point, Individual Products are NOT checked to see if they have already been counted so I need to know if you even need that check or not ...

    Duplicate count matters if you need a comparison to total items in cart and I think that you do ...

    However, if you do not need any Individual Product counts, then just the test for the Master/Linked categories should be good ...
    Last edited by Ajeh; 11 Apr 2013 at 06:50 PM.
    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!

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

    Default Re: Flat Rate Shipping - Table Rates - Duplicate for Category Specific Items?

    NOTE: my Category numbers are not YOUR category numbers so you need to adjust for that ...
    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!

  7. #47
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Flat Rate Shipping - Table Rates - Duplicate for Category Specific Items?

    Adjusting with my category numbers and commenting out the product ID test, but is this code intended for table409.php (to enable shipping module) or table.php (to disable shipping module)?

    PHP Code:
    // bof: only show if all Products are from master_categories_id, individual products_id and Linked Categories
      
    if (!IS_ADMIN_FLAG) {
        
    // check the count of a specific field
        
    $chk_catAll 0;
        
    $chk_cats 0;
        
    $chk_catAll $_SESSION['cart']->count_contents();
        
    // check how many Products are in the cart for master_categories_id 409 etc
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','409');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','7');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','103');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','104');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','105');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','336');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','372');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','361');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','397');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','395');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','385');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','401');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','400');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','391');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','394');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','384');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','387');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','399');
        
    $chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','390'); 
        echo 
    'Products master_categories_id Found: ' $chk_cats '<br>';


     
    //------------------------------------------------------------------------------------
        // check individual products_id 168, 169, 172
      //  $chk_products_found = 0;
      //  $chk_products = $_SESSION['cart']->get_products();
      //  for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
      //    if ( in_array((int)$chk_products[$i]['id'], array(168, 169, 172)) ) {
      //      $chk_products_found += $chk_products[$i]['quantity'];
      //    }
      //  }
    // echo 'Products Individual Found: ' . $chk_products_found . '<br>';
    //--------------------------------------------------------------------------------------
      
      
      
        // check Products from Linked Categories 409 etc
        
    $chk_linked $db->Execute("SELECT distinct products_id FROM products_to_categories WHERE categories_id IN (409, 7, 103, 104, 105, 336, 372, 361, 397, 395, 385, 401, 391, 400, 394, 384, 387, 399, 390)");
        while(!
    $chk_linked->EOF) {
          
    $selected_products_check .= $chk_linked->fields['products_id'];
          
    $chk_linked->MoveNext();
          if (!
    $chk_linked->EOF) {
            
    $selected_products_check .= ',';
          }
        }
        
    $selected_products explode(','$selected_products_check);
        
    // check cart contents for linked products
        
    $chk_products_linked $chk_products;
        
    $chk_products_found_linked 0;
        for (
    $i=0$n=sizeof($chk_products_linked); $i<$n$i++) {
          if ( 
    in_array((int)$chk_products_linked[$i]['id'], $selected_products) ) {
            
    $chk_products_found_linked += $chk_products_linked[$i]['quantity'];
          }
        }
    echo 
    'Products Linked Found: ' $chk_products_found_linked '<br>';

        
    // if any are found turn off the shipping module
        
    if (($chk_cats $chk_products_found $chk_products_found_linked) != $chk_catAll) {
          
    $this->enabled false;
        }
      }
    // eof: only show if all Products are from master_categories_id, individual products_id and Linked Categories 

    It's not echoing that products from the linked cats are there. So, it's not counting them still. I have this added to table409.php though. Is this intended for table.php? I have difficulty understanding some real basics like == or != or = so it confuses me which file this is for

  8. #48
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Flat Rate Shipping - Table Rates - Duplicate for Category Specific Items?

    Smarter code in table409.php:

    PHP Code:
    // bof: only show if all Products are from individual products_id and Master/Linked Categories
      
    if (!IS_ADMIN_FLAG) {


    //-------------------------------------------------------------------------------------------------
        // check individual products_id 168, 169, 172
    //    $chk_products_found = 0;
    //    $chk_products = $_SESSION['cart']->get_products();
    //    for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
    //      if ( in_array((int)$chk_products[$i]['id'], array(168, 169, 172)) ) {
    //        $chk_products_found += $chk_products[$i]['quantity'];
    //      }
    //   }
    //echo 'Products Individual Found: ' . $chk_products_found . '<br>';
    //-------------------------------------------------------------------------------------------------


        // check Products from Linked Categories 5, 10, 22
        
    $chk_linked $db->Execute("SELECT distinct products_id FROM " TABLE_PRODUCTS_TO_CATEGORIES " WHERE categories_id IN (409, 7, 103, 104, 105, 336, 372, 361, 397, 395, 385, 401, 391, 400, 394, 384, 387, 399, 390)");
        while(!
    $chk_linked->EOF) {
          
    $selected_products_check .= $chk_linked->fields['products_id'];
          
    $chk_linked->MoveNext();
          if (!
    $chk_linked->EOF) {
            
    $selected_products_check .= ',';
          }
        }
        
    $selected_products explode(','$selected_products_check);
        
    // check cart contents for linked products
        
    $chk_products_linked $chk_products;
        
    $chk_products_found_linked 0;
        for (
    $i=0$n=sizeof($chk_products_linked); $i<$n$i++) {
          if ( 
    in_array((int)$chk_products_linked[$i]['id'], $selected_products) ) {
            
    $chk_products_found_linked += $chk_products_linked[$i]['quantity'];
          }
        }
    echo 
    'Products Master/Linked Found: ' $chk_products_found_linked '<br>';

        
    $chk_cat_total = ($chk_products_found $chk_products_found_linked);

        
    // if any Products are found and does not match ALL products in cart turn off the shipping module
        
    if (($chk_cat_total) != $chk_catAll) {
          
    $this->enabled false;
        }
      }
    // eof: only show if all Products are from individual products_id and Master/Linked Categories 

  9. #49
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Flat Rate Shipping - Table Rates - Duplicate for Category Specific Items?

    With the smarter code in table409.php and with three products from linked cats and one product from a master cat in cart at checkout page:

    Products Master/Linked Found: 0

    Both table.php and table409.php are showing as options at the checkout page.

  10. #50
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Flat Rate Shipping - Table Rates - Duplicate for Category Specific Items?

    Then with one master cat product in the cart:

    Products Master/Linked Found: 0

    ..... but only the table409.php option available.

    I think I need to edit the opposite code into table.php with a sneaky != somewhere?

 

 
Page 5 of 10 FirstFirst ... 34567 ... LastLast

Similar Threads

  1. free shipping for specific zip code, flat rate otherwise
    By newdre in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 11 Jan 2012, 11:39 AM
  2. Flat Rate Shipping for Small Items
    By AirsoftOutfitter in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 18 Mar 2010, 10:22 PM
  3. Calculate shipping on all items, except flat rate on specific category
    By buckit in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 1 Dec 2009, 06:24 PM
  4. Flat rate just for a set cities and UPS or USPS shipping rates for States
    By pkalout in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 9 Oct 2009, 04:20 PM
  5. Flat Rate shipping challenge - need a separate rate for a few heavier items
    By Nigel Lew in forum Built-in Shipping and Payment Modules
    Replies: 9
    Last Post: 27 Jun 2008, 10:07 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