Flat rate shipping based on master category ID?
Hello all,
I'm trying to sort out shipping within my development site.
I need 3 types of flat rate shipping.
1 ) Livestock, ( eg, cat ID's 1, 4 & 5 )
2 ) Drystock ( eg, cat ID's 2 & 6 )
3 ) Mix of both (eg, Cat ID's 1, 4 & 6 )
I *think* I need to duplicate the flat rate shipping module twice ( giving me 3 flat rates ), then have them check the basket for items within selected categories and then estimate shipping based on that?
1 would be £8.00
2 would be £5
3 would be £10
My PHP knowledge isn't the best so I was hoping someone might be able to help with my query?
Jake
Re: Flat rate shipping based on master category ID?
I buy 12 Products from master_categories_id 1, 4 and 5 and pay just £8.00, correct?
I buy 12 Products from master_categories_id 2 and 6 and pay just £5, correct?
I buy 12 Products from master_categories_id 1, 2, 4, 5 and 6 and pay just £10, correct?
Re: Flat rate shipping based on master category ID?
Yes that is correct :) Prices stay the same regardless of quantities purchased :)
Re: Flat rate shipping based on master category ID?
The cloning the Flat Rate flat module would be the best choice and then customize when each of the modules show based on the content of the shopping cart ...
Re: Flat rate shipping based on master category ID?
Quote:
Originally Posted by
Ajeh
The cloning the Flat Rate flat module would be the best choice and then customize when each of the modules show based on the content of the shopping cart ...
Thanks that is what I was thinking.
Any idea of the codes needed for each module in order for them to check the cart contents?
Re: Flat rate shipping based on master category ID?
You can use the code in RED and adapt it as needed:
Code:
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
}
// bof: only show for category 1, 4 and 5
$chk_cat = 0;
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','1');
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','4');
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','5');
if ($chk_cat != $_SESSION['cart']->show_total()) {
$this->enabled = false;
}
// eof: only show for category 1, 4 and 5
Re: Flat rate shipping based on master category ID?
Quote:
Originally Posted by
Ajeh
You can use the code in
RED and adapt it as needed:
Code:
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
}
// bof: only show for category 1, 4 and 5
$chk_cat = 0;
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','1');
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','4');
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','5');
if ($chk_cat != $_SESSION['cart']->show_total()) {
$this->enabled = false;
}
// eof: only show for category 1, 4 and 5
Thanks very much for that :)
Re: Flat rate shipping based on master category ID?
I've managed to clone the shipping module and update them for Livestock & Drystock, but I can't work out the third one for "mixed" orders containing both.
Does it actually need it's own code adding, or not due to the other codes using single category ID's ( i.e, if two different ID's were used ( 2 & 6 ), would the standard flat rate shipping come into play?
Re: Flat rate shipping based on master category ID?
Also, you need to add for the Admin an IF around the new code:
Code:
if (!IS_ADMIN_FLAG) {
// new code here
}
For checking it is a mixed cart try:
Code:
// bof: only show for mixed cart category 1, 4 and 5 & category 2 and 6
if (!IS_ADMIN_FLAG) {
$chk_cat = 0;
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','1');
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','4');
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','5');
$chk_cat2 = 0;
$chk_cat2 += $_SESSION['cart']->in_cart_check('master_categories_id','2');
$chk_cat2 += $_SESSION['cart']->in_cart_check('master_categories_id','6');
//echo 'Flat sees $chk_cat: ' . $chk_cat . ' $chk_cat2: ' . $chk_cat2 . '<br>';
if ($this->enabled && ($chk_cat > 0 && $chk_cat2 > 0)) {
$this->enabled = true;
} else {
$this->enabled = false;
}
}
// eof: only show for mixed cart category 1, 4 and 5 & category 2 and 6
That echo can be uncommented for testing purposes ...
Re: Flat rate shipping based on master category ID?
Quote:
Originally Posted by
Ajeh
Also, you need to add for the Admin an IF around the new code:
Code:
if (!IS_ADMIN_FLAG) {
// new code here
}
For checking it is a mixed cart try:
Code:
// bof: only show for mixed cart category 1, 4 and 5 & category 2 and 6
if (!IS_ADMIN_FLAG) {
$chk_cat = 0;
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','1');
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','4');
$chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','5');
$chk_cat2 = 0;
$chk_cat2 += $_SESSION['cart']->in_cart_check('master_categories_id','2');
$chk_cat2 += $_SESSION['cart']->in_cart_check('master_categories_id','6');
//echo 'Flat sees $chk_cat: ' . $chk_cat . ' $chk_cat2: ' . $chk_cat2 . '<br>';
if ($this->enabled && ($chk_cat > 0 && $chk_cat2 > 0)) {
$this->enabled = true;
} else {
$this->enabled = false;
}
}
// eof: only show for mixed cart category 1, 4 and 5 & category 2 and 6
That echo can be uncommented for testing purposes ...
I've implemented the above but it doesn't seem to work.
I've got the flat rate shippings to display, but the cheapest shipping option comes up bold on checkout and allows checkout regardless of category number.
I need it to automatically select shipping based on category ID or even automatically add the correct shipping to customer total at checkout?