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:
Views: 25,150
Oba-san
What are you trying to do ...
Can you show some examples? :unsure:
Zen Follower
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.
Oba-san
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?
Zen Follower
I would like all the categories at the same flat rate 0f 7.50 except for the accessories at 3.50.
Oba-san
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?
Zen Follower
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
Oba-san
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) {
New Zenner
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
New Zenner
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
$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
New Zenner
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
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!
New Zenner
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);
}
}
Oba-san
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
Zen Follower
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:
Oba-san
Thanks for the update that this is helped you out ... :smile:
Zen Follower
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.
Oba-san
Could you look in your directory:
/cache
and see what debug logs are generated and what the errors are?
Zen Follower
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.
Oba-san
Kind of odd ...
Can you post the two files that you created?
Zen Follower
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.
Oba-san
ALL of the flat become flatsml and ALL of the FLAT become FLATSML ...
Tell staff why this post should be reviewed.