Zen Cart Logo

Flat shipping query

Views: 1,492

Results 1 to 13 of 13
25 Mar 2013, 5:05 PM
#1
denver_freeburn avatar

denver_freeburn

New Zenner

Join Date:
Mar 2013
Location:
Portadown, United Kingdom
Posts:
16
Plugin Contributions:
0

Flat shipping query

Hi.

I have two shipping prices on my shop.
Anything is £5.95 shipping
But products that are only £1 should have £1 shipping
Is there any way to achieve this?

(I'm comfortable editing code)

Regards,
Denver

25 Mar 2013, 5:10 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Flat shipping query

If this is based on Product Quantity * 5.95 or 1.00 depending on the Product, you could use the Per Unit perweightunit where you set the Product Weight to be the actual shipping charge, as in this case, either 5.95 or 1.00 and set in the Configuration ... Shipping/Packaging ... the Maximum Weight to 5000 and the Tare Rates to 0:0 ...

8 Apr 2013, 4:38 PM
#3
denver_freeburn avatar

denver_freeburn

New Zenner

Join Date:
Mar 2013
Location:
Portadown, United Kingdom
Posts:
16
Plugin Contributions:
0

Re: Flat shipping query

Hi

I have done this, but now whenever I view my cart with 2 or more products in it and estimate the shipping, it ends up with X * 5.95 or X * 1.00.
The desired shipping should be either 1.00 or 5.95 whether 1 product or 200

I have looked about in the admin panel and googled a little but still unable to find a solution

8 Apr 2013, 4:51 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Flat shipping query

What should happen if I have 1 Product that should be $1.00 shipping and 1 Product that should be $5.95 shipping in the order?

What should happen if I have 5 Product that should be $1.00 shipping and 1 Product that should be $5.95 shipping in the order?

What should happen if I have 1 Product that should be $1.00 shipping and 5 Product that should be $5.95 shipping in the order?

8 Apr 2013, 4:57 PM
#5
denver_freeburn avatar

denver_freeburn

New Zenner

Join Date:
Mar 2013
Location:
Portadown, United Kingdom
Posts:
16
Plugin Contributions:
0

Re: Flat shipping query

  1. $5.95 (preferred) - $6.95 (acceptable)
  2. $5.95 (preferred) - $6.95 (acceptable)
  3. $5.95 (preferred) - $6.95 (acceptable)
8 Apr 2013, 5:01 PM
#6
denver_freeburn avatar

denver_freeburn

New Zenner

Join Date:
Mar 2013
Location:
Portadown, United Kingdom
Posts:
16
Plugin Contributions:
0

Re: Flat shipping query

The $1.00 shipping should only be applied if all items in the cart are $1.00

8 Apr 2013, 5:20 PM
#7
ajeh avatar

ajeh

Oba-san

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

Re: Flat shipping query

Here is the plan ...

Still use the Product Weight of 1.00 to 5.95 to indicate the shipping charge on Products ...

To charge either $1.00 or $5.95 or $6.95 based regardless of quantity use the Per Item item shipping module and add the code in RED:

// class methods
    function quote($method = '') {
      global $order, $total_count;

[B]// bof: charge $1 or $5.95 or $6.95
$chk_1 = $_SESSION['cart']->in_cart_check('products_weight','1');
$chk_595 = $_SESSION['cart']->in_cart_check('products_weight','5.95');
$new_shipping = 0;
if ($chk_1 > 0) {
  $new_shipping = 1;
}
if ($chk_595 > 0) {
  $new_shipping += 5.95;
}

//echo 'Products for 1 lb: ' . $chk_1 . '<br>';
//echo 'Products for 5.95 lb: ' . $chk_595 . '<br>';
//echo 'New shipping charge: ' . $new_shipping . '<br>';
[/B]
      // adjusted count for free shipping
      $item_total_count = $total_count - $_SESSION['cart']->free_shipping_items();
      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_ITEM_TEXT_WAY,
                                                     'cost' => [B]$new_shipping[/B] + MODULE_SHIPPING_ITEM_HANDLING)));
[B]// eof: charge $1 or $5.95 or $6.95
[/B]
      if ($this->tax_class > 0) {

If you decide you do not want the $6.95 charge if both 1.00 and 5.95 is in the cart and just want $5.95, then remove the** +** on this line:

  $new_shipping = 5.95;
8 Apr 2013, 5:59 PM
#8
denver_freeburn avatar

denver_freeburn

New Zenner

Join Date:
Mar 2013
Location:
Portadown, United Kingdom
Posts:
16
Plugin Contributions:
0

Re: Flat shipping query

That part works fine, however (you're bound to hate me right now)
These two lines:
$chk_1 = $_SESSION['cart']->in_cart_check('products_weight','1');
$chk_595 = $_SESSION['cart']->in_cart_check('products_weight','5.95');

need to be:
$chk_1 = $_SESSION['cart']->in_cart_check('products_attributes_weight','1');
$chk_595 = $_SESSION['cart']->in_cart_check('products_attributes_weight','5.95');

as each product has two entries in the products_attributes table.
I've attempted to make the necsessary changes to includes/classes/shopping_cart.php but it just comes up with an error

Line 1539: $product_check = $db->Execute("select " . $check_what . " as check_it from ".[B]TABLE_PRODUCTS_ATTRIBUTES[/B]." where products_id='" . $testing_id . "' limit 1");

Error:
WARNING: An Error occurred, please refresh the page and try again

8 Apr 2013, 6:03 PM
#9
ajeh avatar

ajeh

Oba-san

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

Re: Flat shipping query

Yes ... I hate you ... :smile:

When I get some time later on tonight I will work out a new way to do this for you ... meanwhile, don't break the shopping_cart class as there are other things that may be using the function ...

8 Apr 2013, 6:10 PM
#10
denver_freeburn avatar

denver_freeburn

New Zenner

Join Date:
Mar 2013
Location:
Portadown, United Kingdom
Posts:
16
Plugin Contributions:
0

Re: Flat shipping query

Blame my boss, not me :p

I'll revert all the changes I made and thank you for all your time :)

8 Apr 2013, 8:31 PM
#11
ajeh avatar

ajeh

Oba-san

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

Re: Flat shipping query

Okay .. new method same file:

// class methods
    function quote($method = '') {
      global $order, $total_count;

[B]// bof: charge $1 or $5.95 or $6.95
$new_shipping = 0;
$chk_1 = 0;
$chk_595 = 0;
$chk_products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
  if ($chk_products[$i]['weight'] == 1.00) {
    $chk_1 = $chk_1 + $chk_products[$i]['quantity'];
  }
  if ($chk_products[$i]['weight'] == 5.95) {
    $chk_595 = $chk_595 + $chk_products[$i]['quantity'];
  }
//  echo 'ID: ' . (int)$chk_products[$i]['id'] . ' Name: ' . $chk_products[$i]['name'] . ' weight: ' . $chk_products[$i]['weight'] . ' qty: ' . $chk_products[$i]['quantity'] . '<br>';
}
$new_shipping = 0;
if ($chk_1 > 0) {
  $new_shipping = 1;
}
if ($chk_595 > 0) {
  $new_shipping += 5.95;
}

//echo 'New shipping charge: ' . $new_shipping . '<br>';
[/B]
      // adjusted count for free shipping
      $item_total_count = $total_count - $_SESSION['cart']->free_shipping_items();
      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_ITEM_TEXT_WAY,
                                                     'cost' => [B]$new_shipping[/B] + MODULE_SHIPPING_ITEM_HANDLING)));
[B]// eof: charge $1 or $5.95 or $6.95
[/B]
      if ($this->tax_class > 0) {
8 Apr 2013, 10:28 PM
#12
denver_freeburn avatar

denver_freeburn

New Zenner

Join Date:
Mar 2013
Location:
Portadown, United Kingdom
Posts:
16
Plugin Contributions:
0

Re: Flat shipping query

Ajeh, thank you very much!
That is absolutely perfect!
Lifesaver
10 points
Mucho gracias
irayo

9 Apr 2013, 12:33 AM
#13
ajeh avatar

ajeh

Oba-san

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

Re: Flat shipping query

You are most welcome ... remember the Zen Cart Team when you are rich and famous ... :cool: