Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Shipping Class A Flate Rate Shipping Class B Fedex, How to charge WordPress

  • REFUNDED

both in the cart. I can not believe I am the first person in the history of woo commerce to need this. I found this thread http://mikejolley.com/2013/12/manipulating-shipping-packages-woocommerce-2-1/ but its using two seperate flat rates, I want to use fedex for one class and flat rate for another and have people be able to buy from both!

The issue is that we are shipping full cases by fedex from one warehouse and broken cases from another warehouse for a flat rate. Woo not only is missing this, it seems to actively not want you to do it.

Answers (4)

2015-01-22

Romel Apuya answers:

is this extension you are looking for?
[[LINK href="http://docs.woothemes.com/document/per-product-shipping/"]]http://docs.woothemes.com/document/per-product-shipping/[[/LINK]]


DanLewis comments:

I wish, that mainly works for flate rates, you have to define a rate for each product, the fedex rates would be based on weight and the plugin does the pricing for you. I just want everything in that class to default to fedex and then if they also buy something from the flat rate shipping I want to charge both rates.


Romel Apuya comments:

hi,

here's the method i used..

1. Define shipping classes
under products->shipping classes
a. fedex
b. bulky
2. on shipping methods
a. activate flat rate
b. set Costs Added... to
Per Class - charge shipping for each shipping class in an order
(you can also try per item)
c. added Costs: bulky = 10(set anything you want)
d save changes.
3. on shipping methods
a. activate local delivery (activate Fedex in your case)
b. i used local delivery since i dont have the fedex plugin
just set the fee or cost..
c. save changes
4. add products with different classes from the shipping tab. and save each products
5. copy this to your functions.php of the active theme


add_filter( 'woocommerce_cart_shipping_packages', 'bulky_woocommerce_cart_shipping_packages' );
function bulky_woocommerce_cart_shipping_packages( $packages ) {
// Reset the packages
$packages = array();
// Bulky items
$bulky_items = array();
//$regular_items = array();
$fedex_items = array(); // will store our fedex items here
// Sort bulky from regular
foreach ( WC()->cart->get_cart() as $item ) {
if ( $item['data']->needs_shipping() ) {
if ( $item['data']->get_shipping_class() == 'bulky' ) {
$bulky_items[] = $item;
} else if($item['data']->get_shipping_class() == 'fedex'){
$fedex_items[] = $item; //if fedex...
}else{

}
}
}
if ( $fedex_items ) {
$packages[] = array(
'ship_via' => array( 'local_delivery' ), /** change this to the section name of fedex something from the url ?page=wc-settings&tab=shipping&section=wc_shipping_local_delivery just use the text after wc_shipping_ **/
'contents' => $fedex_items,
'contents_cost' => array_sum( wp_list_pluck( $fedex_items, 'subtotal' ) ),
'applied_coupons' => WC()->cart->applied_coupons,
'destination' => array(
'country' => WC()->customer->get_shipping_country(),
'state' => WC()->customer->get_shipping_state(),
'postcode' => WC()->customer->get_shipping_postcode(),
'city' => WC()->customer->get_shipping_city(),
'address' => WC()->customer->get_shipping_address(),
'address_2' => WC()->customer->get_shipping_address_2()
)
);
}
// Put inside packages
if ( $bulky_items ) {
$packages[] = array(
'ship_via' => array( 'flat_rate' ),
'contents' => $bulky_items,
'contents_cost' => array_sum( wp_list_pluck( $bulky_items, 'line_total' ) ),
'applied_coupons' => WC()->cart->applied_coupons,
'destination' => array(
'country' => WC()->customer->get_shipping_country(),
'state' => WC()->customer->get_shipping_state(),
'postcode' => WC()->customer->get_shipping_postcode(),
'city' => WC()->customer->get_shipping_city(),
'address' => WC()->customer->get_shipping_address(),
'address_2' => WC()->customer->get_shipping_address_2()
)
);
}
return $packages;
}


please test and let me know..
you might have error.. since im not sure of the fedex settings but i can take a look if you want..


DanLewis comments:

Is this with that plugin you mentioned?


The fedex plugin quotes the rates from fedex so having to manually set the rates would be counter productive.


DanLewis comments:

They also want the customer to be able to choose overnight, 2day etc wich is in the fedex plugin so I cant leave that out.


Romel Apuya comments:

no.. its with your current fedex plugin..
you've mentioned that you have one, right?
if you wont mind i can look into your woccommerce installation and
execute changes.. you can send details via PM
the fedex shipping class on the product is just a way of telling that its using fedex..
so all calculations by fedex will also be used..


Romel Apuya comments:

i have tested it in my local..
same concept i guess but still have to change on your current woocommerce installation
this part
'contents_cost' => array_sum( wp_list_pluck( $fedex_items, 'subtotal' ) ),
might not be correct for all
you can try a var_dump of $fedex_items (i.e var_dump($fedex_items)) and see values..

but if you wont mind i can look into the fedex shipping code and adjust the code on functions.php

so fedex calculations will never be affected..

PS: ived PM'ed you many times.. but seems your not getting the message??
add me on skype: rrapuya

cheers,

2015-01-22

Arnav Joy answers:

Hello Dan,
Can you let me know what is there in your site right now and what you want ?
-Arnav


DanLewis comments:

I have purchased every possible plugin none of them work.

2015-01-22

Dbranes answers:

In the example link you provided, the "class A" shipping class products have

'ship_via' => array( 'flat_rate' ),


so it uses only the flat rate.

Did you try to lock down the shipping method for "class B" shipping class products, with for example:

'ship_via' => array( 'fedex' ),


on the second package, where you have to adjust it for the correct array key?

I guess you also have to change 'bulky' to 'class-a' in this line:

if ( $item['data']->get_shipping_class() == 'bulky' ) {



DanLewis comments:

I dont think that would make both shipping methods show in the checkout, with fedex there is a drop down, Would it be possible to just add 9.95 to the fedex rates if there is a product from the flat rate group?


DanLewis comments:

actually no, because that would be disabling flate rate and it needs to be there for the other products on their own.

2015-01-23

Gabriel Reguly answers:

Hi Dan,

You are not the first to need it and the solution is not too complicated.

Just add the Class A Flat Rate values to the Fedex options.

I can code it for you, but then the prize is not enough.

If you could raise it to $300 then I would gladly make a plugin to solve the issue.

Cheers,
Gabriel