Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18
  1. #11
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,303
    Plugin Contributions
    1

    Default Re: HELP Zones Shipping (Extra Cost For Large Items)

    Quote Originally Posted by Ajeh View Post
    You would need to edit the Zone Rates zones and the Free Shipping Options freeoptions for this ...

    This would add that extra charge to both shipping methods ...

    For the Zone Rates zones, edit the file with the code in RED:
    /includes/modules/shipping/zones.php

    Code:
    // bof: check for oversized items and charge £15.00 extra per item
    global $cart;
    $chk_oversized = 0;
    $oversized_title = '';
    $chk_oversized += $_SESSION['cart']->in_cart_check('products_id', '1053');
    $chk_oversized += $_SESSION['cart']->in_cart_check('products_id', '1046');
    $chk_oversized += $_SESSION['cart']->in_cart_check('products_id', '3242');
    $extra_shipping = $chk_oversized * 15.00;
    if ($extra_shipping > 0) {
    $oversized_title = '+ overweight shipping surcharge';
    } else {
      $oversized_title = '';
    }
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => $shipping_method . $oversized_title,
                                                         'cost' => $shipping_cost + $extra_shipping)));
    So glad I came across this bit of code. I've applied it to a Table Rate clone and I want to be able to check the cart for an oversized item as defined by its attribute. Just adding

    Code:
    $chk_oversized += $_SESSION['cart']->in_cart_check('products_attributes_id', '8');
    doesn't work because, I think, that in_cart_check is looking in TABLE_PRODUCTS.

    It may be that I need to code another function in includes\classes\shopping_cart.php to allow for a check in TABLE_PRODUCTS_ATTRIBUTES, just guessing really. Does anyone have any suggestions as to how to include an attribute check in this oversized items code?

  2. #12
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,303
    Plugin Contributions
    1

    Default Re: HELP Zones Shipping (Extra Cost For Large Items)

    Well blow me down! It seems I was on the right track.

    I added

    Code:
    $chk_oversized += $_SESSION['cart']->in_cart_check_attrib('products_attributes_id', '8');
    into Ajeh's code and created this new function in shopping_cart.php

    Code:
    /* Method to calculate the number of items in a cart based on an attribute property */
      
       function in_cart_check_attrib($check_what, $check_value='1') {
        global $db;
        // if nothing is in cart return 0
        if (!is_array($this->contents)) return 0;
    
        // compute total quantity for field
        $in_cart_check_qty=0;
    
        reset($this->contents);
        while (list($products_id, ) = each($this->contents)) {
          $testing_id = zen_get_prid($products_id);
          // check if field it true
          $product_check = $db->Execute("select " . $check_what . " as check_it from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $testing_id . "' limit 1");
          if ($product_check->fields['check_it'] == $check_value) {
            $in_cart_check_qty += $this->contents[$products_id]['qty'];
          }
        }
        return $in_cart_check_qty;
      }
    Seems to work fine.

  3. #13
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,303
    Plugin Contributions
    1

    Default Re: HELP Zones Shipping (Extra Cost For Large Items)

    Ok, still need a bit of help on this.

    The 'check for oversized items' is identifying the product just because it has the desired attribute, not because the product has that attribute selected in the shopping cart.

    Suggestions welcome.

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

    Default Re: HELP Zones Shipping (Extra Cost For Large Items)

    Is this products_attributes_id 8 the only Attribute on this Product?
    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!]
    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. #15
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,303
    Plugin Contributions
    1

    Default Re: HELP Zones Shipping (Extra Cost For Large Items)

    No, it also has a products_attributes_id of '7'

    No Frame - products_attributes_id 7 (options_values_id 2)
    With Frame - products_attributes_id 8 (options_values_id 1)

    Only some products have a frame option

    It is products 'With Frame' that need to be classed as oversized

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

    Default Re: HELP Zones Shipping (Extra Cost For Large Items)

    Would something like this work for you?
    Code:
    /* Method to calculate the number of items in a cart based on an attribute option_id and option_values_id combo */
    // example: $_SESSION['cart']->in_cart_check_attrib_quantity(1, 16)
    
      function in_cart_check_attrib_quantity($check_option_id, $check_option_values_id) {
    //    global $db;
        // if nothing is in cart return 0
        if (!is_array($this->contents)) return 0;
    
        // compute total quantity for field
        $in_cart_check_qty = 0;
    
        $chk_products = $this->get_products();
        for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
          foreach ($chk_products[$i]['attributes'] as $option => $value) {
            if ($option == $check_option_id && $value == $check_option_values_id) {
    //          echo 'Attribute FOUND FOR $option: ' . $option . ' $value: ' . $value . ' quantity: ' . $chk_products[$i]['quantity'] . '<br><br>';
              $in_cart_check_qty += $chk_products[$i]['quantity'];
            }
          }
        }
        return $in_cart_check_qty;
      }
    I have an idea to expand a similar function with more flexibility in the future but I am still giving it a think ...
    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!]
    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. #17
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,303
    Plugin Contributions
    1

    Default Re: HELP Zones Shipping (Extra Cost For Large Items)

    Quote Originally Posted by Ajeh View Post
    Would something like this work for you?
    Code:
    /* Method to calculate the number of items in a cart based on an attribute option_id and option_values_id combo */
    // example: $_SESSION['cart']->in_cart_check_attrib_quantity(1, 16)
    
      function in_cart_check_attrib_quantity($check_option_id, $check_option_values_id) {
    //    global $db;
        // if nothing is in cart return 0
        if (!is_array($this->contents)) return 0;
    
        // compute total quantity for field
        $in_cart_check_qty = 0;
    
        $chk_products = $this->get_products();
        for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
          foreach ($chk_products[$i]['attributes'] as $option => $value) {
            if ($option == $check_option_id && $value == $check_option_values_id) {
    //          echo 'Attribute FOUND FOR $option: ' . $option . ' $value: ' . $value . ' quantity: ' . $chk_products[$i]['quantity'] . '<br><br>';
              $in_cart_check_qty += $chk_products[$i]['quantity'];
            }
          }
        }
        return $in_cart_check_qty;
      }
    I have an idea to expand a similar function with more flexibility in the future but I am still giving it a think ...

    I think that is exactly what I needed, the couple of checks I've made seem to work well - I'll test more once I've fully set up my shipping and hopefully give some feedback/suggestions for your future design.

    This last bit of help was all I needed to finalise my shipping costs (until I find something else!) so thank you very much.

    I've sent the Team a coffee and donut.

    Cheers

    Simon

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

    Default Re: HELP Zones Shipping (Extra Cost For Large Items)

    Thanks for the update that this was able to work for you ...

    The Zen Cart Team also appreciates the support ... we really love those coffees and donuts!
    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!]
    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!

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. v150 One shipping cost for some items then flat rate for 2 or more
    By annav in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 27 Jun 2013, 06:02 PM
  2. Increase Shipping Cost for Larger Items
    By mned in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 20 Aug 2010, 02:45 PM
  3. Different shipping cost for some items?
    By Treasuresbycaz in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 1 Jan 2009, 09:36 PM
  4. Same shipping cost for up to X items, then increment shipping after that
    By infinitecreature in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 4 Dec 2008, 07:03 AM
  5. Shipping cost for 7 different zones ??
    By Xam in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 9 Apr 2008, 02:16 PM

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