Re: Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories
I know something is wrong with what I have now because check out goes to a white page, but am I closer?
PHP Code:
global $cart;
//check if manufacturer alchemy is in cart
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy') > 0)); {
$manufacturer_alchemy = $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy');
$drop_ship_extra_charge = $manufacturer_alchemy;
}
// charge dropship fee for alchemy
if ($drop_ship_extra_charge > 0) {
$cat_extra_charge = 10;
'cost' => ($cat_extra_charge + MODULE_SHIPPING_USPS_HANDLING);
echo 'An additional $10 shipping fee for Alchemy items has been applied.';
} else {
$cat_extra_charge = 0;
}
Re: Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories
Oh, and I forgot to say I didn't try to make the php count how many Alchemy products are in the cart because whether there are one or many, only one $10 fee will be added. Unless it's still necessary to count them, and that's what's messing this all up.....
Re: Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories
You are not using the cost correctly ...
The whole section in there should look like:
Code:
global $cart;
//check if manufacturer alchemy is in cart
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy') > 0)); {
$manufacturer_alchemy = $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy');
$drop_ship_extra_charge = $manufacturer_alchemy;
}
// charge dropship fee for alchemy
if ($drop_ship_extra_charge > 0) {
$cat_extra_charge = 10;
echo 'An additional $10 shipping fee for Alchemy items has been applied.';
} else {
$cat_extra_charge = 0;
}
$methods = array();
$size = sizeof($uspsQuote);
for ($i=0; $i<$size; $i++) {
list($type, $cost) = each($uspsQuote[$i]);
// BOF: UPS USPS
$title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) $title .= $transittime[$type];
/*
$methods[] = array('id' => $type,
'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
*/
$cost = preg_replace('/[^0-9.]/', '', $cost);
$methods[] = array('id' => $type,
'title' => $title,
'cost' => $cat_extra_charge + ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
}
$this->quotes['methods'] = $methods;
Re: Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories
Well, it took me this long to get my USPS webtools user id and get on their production server, so I couldn't test out these changes I made to usps.php until now.
The php is obviously correct because the usps module is showing and calculating, but it's not calculating the extra $10 fee if there are Alchemy products in the cart.
One Alchemy product alone in the cart with my zip code brought up $5.70 for shipping (and my Alchemy products are all set to 0 weight). I also tested a non-Alchemy product alone and it was over $6 (and set to .04 weight), and then added an Alchemy product, but that didn't change the shipping calculation.
Plus, I guess putting the $10 dropship fee in the USPS module is going to make it look like the Alchemy products are going to be shipped USPS? The manufacturer actually sends them Fed Ex.
Here is what I added, with what comes before and after it so you can see where I put it. Any ideas on what's missing?
PHP Code:
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
}
if ($this->enabled) {
// check MODULE_SHIPPING_USPS_HANDLING_METHOD is in
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_USPS_HANDLING_METHOD'");
if ($check_query->EOF) {
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box', 'MODULE_SHIPPING_USPS_HANDLING_METHOD', 'Box', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
}
}
if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USPS_ZONE > 0) ) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_USPS_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$this->enabled = false;
}
}
$this->types = array('EXPRESS' => 'Express Mail',
'FIRST CLASS' => 'First-Class Mail',
'PRIORITY' => 'Priority Mail',
'PARCEL' => 'Parcel Post',
'MEDIA' => 'Media Mail',
'BPM' => 'Bound Printed Matter',
'LIBRARY' => 'Library'
);
Re: Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories
I am not sure what it is you added and what you posted is the wrong section of code ...
Re: Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories
Oops, I completely cut/paste the wrong section! :lookaroun
Here's what I put and where it is in the file, I'll make my changes red:
Code:
if (is_array($uspsQuote)) {
if (isset($uspsQuote['error'])) {
$this->quotes = array('module' => $this->title,
'error' => $uspsQuote['error']);
} else {
// BOF: UPS USPS
if (in_array('Display weight', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) {
switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
case (0):
$show_box_weight = '';
break;
case (1):
$show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
break;
case (2):
$show_box_weight = ' (' . number_format($usps_shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
break;
default:
$show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($usps_shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
break;
}
}
// EOF: UPS USPS
// BOF: UPS USPS
$this->quotes = array('id' => $this->code,
'module' => $this->title . $show_box_weight);
// EOF: UPS USPS
global $cart;
//check if manufacturer alchemy is in cart
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy') > 0)); {
$manufacturer_alchemy = $_SESSION['cart']->in_cart_check('manufacturers_id','alchemy');
$drop_ship_extra_charge = $manufacturer_alchemy;
}
// charge dropship fee for alchemy
if ($drop_ship_extra_charge > 0) {
$cat_extra_charge = 10;
echo 'An additional $10 shipping fee for Alchemy items has been applied.';
} else {
$cat_extra_charge = 0;
}
$methods = array();
$size = sizeof($uspsQuote);
for ($i=0; $i<$size; $i++) {
list($type, $cost) = each($uspsQuote[$i]);
// BOF: UPS USPS
$title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) $title .= $transittime[$type];
/*
$methods[] = array('id' => $type,
'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
*/
$cost = preg_replace('/[^0-9.]/', '', $cost);
$methods[] = array('id' => $type,
'title' => $title,
'cost' => $cat_extra_charge + ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
}
$this->quotes['methods'] = $methods;
if ($this->tax_class > 0) {
$this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
}
Re: Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories
Change the two 'alchemy' to be the value of the manufacturers_id for alchemy ...
Code:
$_SESSION['cart']->in_cart_check('manufacturers_id','alchemy')
So if the value is 38 use:
Code:
$_SESSION['cart']->in_cart_check('manufacturers_id',38)
Re: Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories
OK, we're super close, I changed those manufacturer id's, and now when I put an Alchemy product in the cart and put my zip, the shipping is $15.70, so it's adding the $10 on top of what usps is calculating for shipping, the only thing is that the usps shouldn't be calculating, I only need the flat $10.
Is this the reason that I needed to also configure the flat.php, for cases when there are only Alchemy products in the cart? I guess I thought the usps module would just not calculate anything because of the 0 weight and just add the dropship charge. Maybe because I haven't taken the tare off? I'll try that.....
Ok, that changed it a bit, but didn't eliminate it. The total including the $10 is coming to $11.22/first class, and $14.90/priority, so the very base amounts.
Is there a way to further change usps.php or is it time to work on flat.php?
Thank you soooooo much for all the help you've given me!
Re: Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories
What are the shipping charges if:
1 Alchemy Product
2 Alchemy Product
3 Alchemy Product
1 Alchemy Product and 1 Regular
2 Alchemy Product and 2 Regular
3 Alchemy Product and 1 Regular
2 Alchemy Product and 2 Regular
Re: Can I apply Flat Rate to one Category & Zone, Per Weight for all other Categories
I tested each of those, and they ALL came out to $14.90 for priority.
So with more than one Alchemy product it correctly only adds one $10 charge, but in call cases, whether it's just Alchemy products or Alchemy plus regular, it's doing the $10 plus the base priority mail charge (the two regular products are light). If I just do the two regular products and no Alchemy, it came it $4.90.....