Zen Follower
- Join Date:
- Sep 2012
- Location:
- West Jefferson, NC
- Posts:
- 391
- Plugin Contributions:
- 0
Multiple Shipping Origins For Dummies?
How can I make an order loop through the normal shipping calculations for multiple shipping origins?
I have read and re-read all the post on here over the last week and I see a lot of interest in this idea but no solutions.
Here is the code I have implemented just before line 208 of modules / MY FILES / shipping_estimator.php.
/*each zip code needs to be processed seperately thru the ups.php module...this gets the zip codes, weights, and quantities for processing*/
//distinct ship zips in order
$ezfeeds_distinct_ship_zips = $db->Execute("select distinct ship_zip
from " . TABLE_PRODUCTS . "
where products_weight > 0
and products_id IN (select products_id from " . TABLE_CUSTOMERS_BASKET . "
where customers_id = '" . (int)$_SESSION['customer_id'] . "')");
if ($ezfeeds_distinct_ship_zips->RecordCount() > 1){
$order_weight = 0;
$order_quantity = 0;
while (!$ezfeeds_distinct_ship_zips->EOF) {
$ezfeeds_distinct_ship_zip = $ezfeeds_distinct_ship_zips->fields['ship_zip'];
$ezfeeds_UPS_products = $db->Execute("select products_id, products_weight, ship_zip
from " . TABLE_PRODUCTS . "
where products_weight > 0
and ship_zip = '$ezfeeds_distinct_ship_zip'
and products_id IN (select products_id from " . TABLE_CUSTOMERS_BASKET . "
where customers_id = '" . (int)$_SESSION['customer_id'] . "')");
$origin_weight = 0;
$origin_quantity = 0;
while (!$ezfeeds_UPS_products->EOF) {
$ezfeeds_ship_zip = $ezfeeds_UPS_products->fields['ship_zip'];
$ezfeeds_produts_id = $ezfeeds_UPS_products->fields['products_id'];
$ezfeeds_products_weight = $ezfeeds_UPS_products->fields['products_weight'];
$ezfeeds_products_name = $db->Execute("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . "
where products_id = '$ezfeeds_produts_id' ");
$ezfeeds_product_name = $ezfeeds_products_name->fields['products_name'];
$ezfeeds_UPS_quantities = $db->Execute("select customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . "
where customers_id = '" . (int)$_SESSION['customer_id'] . "'
and products_id = '$ezfeeds_produts_id' ");
$ezfeeds_products_quantity = $ezfeeds_UPS_quantities->fields['customers_basket_quantity'];
echo "<br>" . $ezfeeds_product_name . "<br>Shipping Origin: " . $ezfeeds_ship_zip . "<br>Individual Weight: " . $ezfeeds_products_weight . "<br>Quantity Ordered: " . $ezfeeds_products_quantity. "<br>";
$ezfeeds_products_weight = $ezfeeds_products_weight * $ezfeeds_products_quantity;
$origin_weight = $origin_weight + $ezfeeds_products_weight;
$origin_quantity = $origin_quantity + $ezfeeds_products_quantity;
$ezfeeds_UPS_products->MoveNext();
}
echo "<br><b>" . $origin_weight . " Shipping Origin Weight<br>";
echo $origin_quantity . " Shiping Origin Quantity</b><br>";
$order_weight = $order_weight + $origin_weight;
$order_quantity = $order_quantity + $origin_quantity;
//change shipping origin to this one for processing order
//require multiple_origins_shipping.php
//build counters to tally total order
$ezfeeds_distinct_ship_zips->MoveNext();
}
echo "<br><b>" . $order_weight." Lbs. Order Weight<br>";
echo $order_quantity." Order Quantity</b><br>";
//change db zip origin back to central point of USA, 67530, just in case a zip is missing
}
/*END MIKE*/
It totals weights and quantites by SESSION and zip code just fine with an output like this:
Sport Hoody Color Gry Size YL
Shipping Origin: 07506
Individual Weight: 1
Quantity Ordered: 1
Performance Tee Color Blk Size YM
Shipping Origin: 07506
Individual Weight: 1
Quantity Ordered: 1
2 Shipping Origin Weight
2 Shiping Origin Quantity
17 X 13 Oval Decor Copper Tray With Cast Brass Handle
Shipping Origin: 07663
Individual Weight: 5
Quantity Ordered: 2
10 Shipping Origin Weight
2 Shiping Origin Quantity
12 Lbs. Order Weight
4 Order Quantity
It does not calculate the UPS shipping cost yet...this is where I need help. I just can not seem to grasp onto the way shipping charges are processed. I've read the code a hundred times and end up with a headache after each attempt to understand how it works.
I have tried extending the end of my ```php
while (!$ezfeeds_distinct_ship_zips->EOF) {
The process stops after the first shipping origin...:frusty:
I have also tried plugging this code into various places in the ups.php, shipping, and other files associated with shipping, but nothing seems to work.
I even looked into osCommerces' MVS (multiple vendor support) module and I'm still confused.
I really would appreciate any help I can get with this.