Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1
    Join Date
    Dec 2011
    Posts
    48
    Plugin Contributions
    0

    Default Fee if certain items are ordered

    Hello. I tried searching for an answer for a few days but couldn't come up with anything. I need to be able to add a special fee for certain items to cover the extra shipping cost incurred. Basically if someone places an order for normal items, there would be no fee. But I need a way to add a fee to the order if these other items are ordered no matter how many of them are ordered. For example let's pretend that I have just two types of items: type A and type B. Type A items are just normal and you pay regular shipping based on weight. Type B items you still pay regular shipping based on weight but they need a $5 fee per order no matter how many are ordered. If both types are ordered then you still pay the $5 fee per order. And I don't care where the fee is placed whether it's in the shipping, handling, low order, etc. I'm not picky, just as long as it works I'll be happy.

    Any help would be appreciated...and I don't mind having to modify anything if necessary.

    Thanks guys and gals.

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

    Default Re: Fee if certain items are ordered

    Let's say you were customizing the Flat Rate flat shipping module, you could use this code:
    Code:
    // bof: add additional charge if products 12 or 15 are in the cart
          global $cart;
          $chk_products = 0;
          $extra_shipping = 0.00;
          $chk_products += $_SESSION['cart']->in_cart_check('products_id','12');
          $chk_products += $_SESSION['cart']->in_cart_check('products_id','15');
          if ($chk_products > 0 ) {
            $extra_shipping = 5.00;
          }
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                         'cost' => MODULE_SHIPPING_FLAT_COST + $extra_shipping)));
    // eof: add additional charge if products 12 or 15 are in the cart
    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
    Dec 2011
    Posts
    48
    Plugin Contributions
    0

    Default Re: Fee if certain items are ordered

    Thank you.

    Would this work for other shipping modules...notably UPS and USPS?

    Also, would it be possible to make a new column in the database under products such as products_fee and have it add the fee if the value is set to 1? I have quite a few and it would be easier to do it that way rather than telling it every products_id.

    Thanks again.

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

    Default Re: Fee if certain items are ordered

    There is always a way to customize the code ... this is Zen Cart ...

    You can add new fields to figure out when to use the extra charge but you would have to write something to check if that field is set in any of the Products in the order ...
    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
    Dec 2011
    Posts
    48
    Plugin Contributions
    0

    Default Re: Fee if certain items are ordered

    So, modifying your code, if I did do that, should the below work? And if I were using the UPS or USPS modules, would I just replace the MODULE_SHIPPING_FLAT_* stuff with the appropriate replacements?

    Code:
    // bof: add additional charge if products with products_fee value of 1 are in the cart
          global $cart;
          $chk_products = 0;
          $extra_shipping = 0.00;
          $chk_products += $_SESSION['cart']->in_cart_check('products_fee','1');
          if ($chk_products > 0 ) {
            $extra_shipping = 5.00;
          }
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                         'cost' => MODULE_SHIPPING_FLAT_COST + $extra_shipping)));
    // eof: add additional charge if products with products_fee value of 1 are in the cart

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

    Default Re: Fee if certain items are ordered

    If the goal is if 1 or more Products are marked as:
    products_fee = 1

    then that will add $5.00 to the cost ...
    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. #7
    Join Date
    Dec 2011
    Posts
    48
    Plugin Contributions
    0

    Default Re: Fee if certain items are ordered

    I'm trying to put this in the USPS module but I cannot get it to work. I changed MODULE_SHIPPING_FLAT* to MODULE_SHIPPING_USPS* assuming that was correct. I'm also not 100% certain where to put it at. Either way, whatever I did isn't working.

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

    Default Re: Fee if certain items are ordered

    It should look like this for USPS make sure you do not miss adding the $extra_shipping to the cost line ...

    Code:
    
    // bof: add additional charge if products with products_fee value of 1 are in the cart
          global $cart;
          $chk_products = 0;
          $extra_shipping = 0.00;
          $chk_products += $_SESSION['cart']->in_cart_check('products_fee','1');
          if ($chk_products > 0 ) {
            $extra_shipping = 5.00;
          }
    
              $methods[] = array('id' => $type,
                                 'title' => $title,
                                 'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? $usps_handling_fee * $shipping_num_boxes : $usps_handling_fee) + $extra_shipping );
    // eof: add additional charge if products with products_fee value of 1 are in the cart
    
    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!

  9. #9
    Join Date
    Dec 2011
    Posts
    48
    Plugin Contributions
    0

    Default Re: Fee if certain items are ordered

    After I realized that it was obvious I was supposed to alter the existing section rather than adding the entire thing in extra it works perfectly. Thanks again.

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

    Default Re: Fee if certain items are ordered

    Thanks for the update that this is now working for you ...
    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!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v139h Automatic message in checkout/shopping basket when certain items are selected
    By christospur in forum Setting Up Categories, Products, Attributes
    Replies: 10
    Last Post: 8 Apr 2013, 06:25 PM
  2. v150 Stopping items on menu to be ordered after a certain time
    By mkyle in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 16 Aug 2012, 01:40 PM
  3. How do I set up a separate handling fee for certain items?
    By flipperry in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 9 Aug 2009, 04:58 PM
  4. Table Rate shipping PLUS a handling fee for certain items
    By marvin in forum Built-in Shipping and Payment Modules
    Replies: 13
    Last Post: 19 Apr 2009, 05:20 PM
  5. Handling fee only on certain items
    By Hound in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 16 Jul 2007, 03:04 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