Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Adding 2 more flat rate shipping modules

Adding 2 more flat rate shipping modules

Views: 25,150

Results 21 to 40 of 55
11 Aug 2011, 5:12 PM
#21
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Adding 2 more flat rate shipping modules

What are you trying to do ...

Can you show some examples? :unsure:

11 Aug 2011, 5:55 PM
#22
tcjay avatar

tcjay

Zen Follower

Join Date:
Jul 2010
Location:
Boston
Posts:
139
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

We sell yarn as well as some smaller accessories. I would like a flat rate on the yarn of 7.50 and a flat rate on the sequins which are much lighter of 3.50.

http://www.stitchboutiqueboston.com/accessories/sequins-p-471/

I would like the flat rate of $3.50 to appear on the sequins.

11 Aug 2011, 6:01 PM
#23
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding 2 more flat rate shipping modules

What about everything else?

Are all Yarn in one Category?

Are all Sequins in one Category?

Are there other Products that this has to happen to?

11 Aug 2011, 6:07 PM
#24
tcjay avatar

tcjay

Zen Follower

Join Date:
Jul 2010
Location:
Boston
Posts:
139
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

I would like all the categories at the same flat rate 0f 7.50 except for the accessories at 3.50.

11 Aug 2011, 6:14 PM
#25
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding 2 more flat rate shipping modules

What should shipping be when I order:

1 Accessory Product?

10 Accessory Products?

1 Accessory Product and 1 non-Accessory Product?

1 Accessory Product and 10 non-Accessory Product?

10 Accessory Product and 1 non-Accessory Product?

11 Aug 2011, 6:24 PM
#26
tcjay avatar

tcjay

Zen Follower

Join Date:
Jul 2010
Location:
Boston
Posts:
139
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

What should shipping be when I order:

1 Accessory Product? 3.5

10 Accessory Products? 3.5

1 Accessory Product and 1 non-Accessory Product? 7.5

1 Accessory Product and 10 non-Accessory Product? 7.5

10 Accessory Product and 1 non-Accessory Product? 7.50

11 Aug 2011, 10:51 PM
#27
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding 2 more flat rate shipping modules

You can customize the Flat Rate flat shipping module:
/includes/modules/flat.php

by customizing the code in RED:

    function quote($method = '') {
      global $order;

// bof: flat rate charges
      global $cart;

      $chk_cat1 = $_SESSION['cart']->in_cart_check('master_categories_id','1');
      $full_cart = $_SESSION['cart']->count_contents();
      if ($chk_cat1 == $full_cart) {
        $flat_charge = 3.50;
      } else {
        $flat_charge = 7.50;
      }

      $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' => $flat_charge)));
// eof: flate rate charges
      if ($this->tax_class > 0) {
15 Sep 2011, 6:00 PM
#28
metasilk avatar

metasilk

New Zenner

Join Date:
Jun 2008
Location:
New England, USA
Posts:
9
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

I am working on a situation that is rather the reverse of the yarns/sequins problem.

I have a set of products (patterns, but they are in multiple categories based on the kind of pattern they are) for which the buyer should get a Low Flat Rate shipping (if they order less than 5 of patterns, say).

However, if anything else is in the cart--books, yarns, etc--the High Flat Rate should apply.

I am not sure how to edit/code this line (or nearby lines) (in /includes/modules/shipping/flat.php) to test for "any of the following category IDs" instead of just one ID:

    $chk_cat1 = $_SESSION['cart']->in_cart_check('master_categories_id','20');

I can get any one of the IDs to work fine, of course, following the pattern you provided in August. Any code help (or a link to a post I couldn't find yet) is most welcome!

(ZC version = the most recent )
(Category IDs include 20, 27, 23, and some others)
(Site: http://www.vtyarnco.com/store/ )
Thanks,
Kir

16 Sep 2011, 6:34 AM
#29
metasilk avatar

metasilk

New Zenner

Join Date:
Jun 2008
Location:
New England, USA
Posts:
9
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

metasilk:

I am working on a situation that is rather the reverse of the yarns/sequins problem.

I have a set of products (patterns, but they are in multiple categories based on the kind of pattern they are) for which the buyer should get a Low Flat Rate shipping (if they order less than 5 of patterns, say).

Hey, I got it. Here is the code (2 categories shown) below. I started with what Ajeh posted in http://www.zen-cart.com/forum/showpost.php?p=1055266&postcount=27 (where she posted an edit to includes/modules/shipping/flat.php that allowed for a custom flat rate for one category).
Then I had to

  1. Add up the results of the in_cart_check by adding a line of code to call this for each category I cared about, and summing those (with +=),
    and
  2. including a check for the final total of items as well
      $chk_cat1 = $_SESSION['cart']->in_cart_check('master_categories_id','20'); // counts how many are of the Hats category
      $chk_cat1 += $_SESSION['cart']->in_cart_check('master_categories_id','26'); // counts how many are of the Mittens category
      $full_cart = $_SESSION['cart']->count_contents(); // counts number of items in the cart in total
      if ( ($chk_cat1 == $full_cart) && ($full_cart<6) ) {
        $flat_charge = 1.50;
      } else {
        $flat_charge = 6.00;
      }

I think this works (2 categories and the counts work, so far). Let me know if you see any screw ups or improvements! Feel free to cross post this to other threads if it's useful...

Hopefully I'm not duplicating the suggestions of forty gazillion other ZCers... :)

--Kir

16 Sep 2011, 9:02 AM
#30
metasilk avatar

metasilk

New Zenner

Join Date:
Jun 2008
Location:
New England, USA
Posts:
9
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

A new puzzle:
Current situation: if you buy 5 or fewer patterns you can get them shipped for a low price. If you buy more patterns, or buy anything else with the pattern, it's shipped for the standard flat rate. Cool.

Now I'd like to add the option: if you buy 5 or fewer patterns, you can choose to have them shipped at a priority mail rate (more than the default low) (and we'll ship them flat, too).

I assume I should clone the flat.php files -- so far so good. I got that cloned and installed through the admin no problem (well, except for the _ I had been using which prevented it from displaying).

But how to change the code so it

  1. checks for the patterns
  2. checks for the number of items
    and THEN enables/disables that new priority mail module according to the results?

So far, it seems this module is all disabled -- no matter what's in the cart, it doesn't show this shipping option. I tried working within the class options (as when I was doing the low rate bit) and up by where modules get disabled when it's all free shipping...

Help welcome!

16 Sep 2011, 9:30 AM
#31
metasilk avatar

metasilk

New Zenner

Join Date:
Jun 2008
Location:
New England, USA
Posts:
9
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

p.s. here's the code in my closed flat shipping file as I am stumped by it (basing my attempts on Ajeh's reply to another post here: http://www.zen-cart.com/forum/showpost.php?p=527844&postcount=5:)

 // moderately experimental change by kjt 09.15.2011
      global $cart;
		// category IDs: 19 (Patterns), 25 Bags, 23 Cardigans, 20 Hats, 26 Mittens, 27 Scarves, 24 Socks, 21 Sweaters, 29 Vests as of 9/15/2011
      $chk_cat1 = $_SESSION['cart']->in_cart_check('master_categories_id','20'); // counts how many are of the Hats category
      $chk_cat1 += $_SESSION['cart']->in_cart_check('master_categories_id','26'); // counts how many are of the Mittens category
      $chk_cat1 += $_SESSION['cart']->in_cart_check('master_categories_id','25'); // counts how many are of the Bags category
      $chk_cat1 += $_SESSION['cart']->in_cart_check('master_categories_id','23'); // counts how many are of the Cardgans category
      $chk_cat1 += $_SESSION['cart']->in_cart_check('master_categories_id','27'); // counts how many are of the Scarves category
      $chk_cat1 += $_SESSION['cart']->in_cart_check('master_categories_id','24'); // counts how many are of the Socks category
      $chk_cat1 += $_SESSION['cart']->in_cart_check('master_categories_id','21'); // counts how many are of the Sweaters category
      $chk_cat1 += $_SESSION['cart']->in_cart_check('master_categories_id','29'); // counts how many are of the Vests category

      $full_cart = $_SESSION['cart']->count_contents(); // counts number of items in the cart in total

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
      // also disable if cart contents include not-patterns or too many patterns
	   if (($chk_cat1 != $full_cart) || ($full_cart > 5)) { 
        $this->enabled = ((MODULE_SHIPPING_FLATpattUSPri_STATUS == 'True') ? true : false);
		}
      }
16 Sep 2011, 1:52 PM
#32
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding 2 more flat rate shipping modules

       if (($chk_cat1 != $full_cart) || ($full_cart > 5)) { 

This checks your specific categories and turns off if:

1 the total cart content does not equal the checked categories so if the number of items in the checked categories is 1 and the full cart is 2 it is off, meaning something is in the cart that is not in the checked categories

2 the total number in the cart regardless of what it is is greater than 5 so if the checked categories is > 5 it turns off or if the combination of things checked and not checked is > 5 it turns off

22 Sep 2011, 10:36 AM
#33
whitephantom avatar

whitephantom

Zen Follower

Join Date:
Jan 2010
Posts:
105
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Thank you so much - the simplest clearest instructions I've seen in a long time!

I just created four clones of the flat rate, edited, uploaded and installed the modules, and they all worked perfectly first time - an unusual enough scenario when trying something new! :clap:

22 Sep 2011, 1:05 PM
#34
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding 2 more flat rate shipping modules

Thanks for the update that this is helped you out ... :smile:

30 Sep 2011, 9:27 AM
#35
amyleew avatar

amyleew

Zen Follower

Join Date:
Jul 2009
Posts:
159
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

I've followed the instructions and changed the module and the languages files. Everything in them says flatsml or FLATSML but when I copy them to the areas by ftp and go and refresh the admin, nothing happens.

30 Sep 2011, 1:19 PM
#36
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding 2 more flat rate shipping modules

Could you look in your directory:
/cache

and see what debug logs are generated and what the errors are?

1 Oct 2011, 11:27 AM
#37
amyleew avatar

amyleew

Zen Follower

Join Date:
Jul 2009
Posts:
159
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Wow. I didn't know there was an error report... what a great tool.

I just did what you said and corrected the line it had a problem with and now it appears in the list in shipping modules in admin but the two fields with name/descriptions are blank and it just has the red stop light as the only thing in the line.

I clicked install on the that line but it didn't work.

1 Oct 2011, 1:07 PM
#38
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding 2 more flat rate shipping modules

Kind of odd ...

Can you post the two files that you created?

1 Oct 2011, 11:29 PM
#39
amyleew avatar

amyleew

Zen Follower

Join Date:
Jul 2009
Posts:
159
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

I'm getting three errors now.

Fatal error: Cannot redeclare class flat in /home4/occxxxp2/public_html/includes/modules/shipping/flatsml.php on line 11

On line 11 there is this -

class flat {
var $code, $title, $description, $icon, $enabled;

Do I put a sml there for flatsml or leave it blank?

Warning: Variable passed to each() is not an array or object in /home4/occxxxp2/public_html/aadmin/modules.php on line 56

On line 56 there is this -

while (list($key, $value) = each($_POST['configuration'])) {

PHP Warning: reset() [<a href='function.reset'>function.reset</a>]: Passed variable is not an array or object in /home4/occxxxp2/public_html/aadmin/modules.php on line 282
[01-Oct-2011 17:20:06] PHP Warning: Variable passed to each() is not an array or object in /home4/occxxxp2/public_html/aadmin/modules.php on line 283

On line 283 there is this -

reset($mInfo->keys);

I don't know how to post or attach the whole files unless I just paste them in a post.

2 Oct 2011, 1:46 AM
#40
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding 2 more flat rate shipping modules

ALL of the flat become flatsml and ALL of the FLAT become FLATSML ...