- Posts: 128
- Thank you received: 3
Set group packages for shipping based on backorder
-- Joomla version -- : 3.5.0
-- PHP version -- : 5.3.24
I have a custom field that allows me to set an item to backorder. What I want to be able to do is if someone places an item in the cart that is on backorder, they can select how to handle the order; whether to hold the order until the backorder items are available or to send the items in stock and send the backorder items later (this would mean I need to disable group packages for the shipping methods). What I currently have is in my checkout->cart view I have changed the code:
to
In the same file I added the code:
How can I get the backordered_items variable into the shipping methods to change the group packages variable value?
Please Log in or Create an account to join the conversation.
- Posts: 12953
- Thank you received: 1778
The solution will probably be to directly edit the "onShippingDisplay" function the shipping plugin that you are actually using.How can I get the backordered_items variable into the shipping methods to change the group packages variable value?
Also, using warehouses will probably do the job to do what you want, you can :
- Create 2 warehouses, one for available/"groupable" products and one for backordered_items
- Then you'll have to set the correct warehouse through your product configuration page but also through your shipping method configuration page
- And finally you'll just have to create and configuration different shipping methods for both kind of products
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Well, the exact solution depends on the shipping method your using and you didn't tell us what it is. That's why I can only repeat what Mohamed said:
Probably with a foreach on $order->products to check the advance_orders value of the products and then force the configuration value ( 0 or 1 ) of the group package option in $rate->shipping_params->group_package (the exact name might vary based on your shipping plugin).The solution will probably be to directly edit the "onShippingDisplay" function the shipping plugin that you are actually using.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
foreach($local_usable_rates as $k => $rate){
in the function onShippingDisplay of the plugins main file plugins/hikashopshipping/fedex/fedex.php and plugins/hikashopshipping/ups/ups.php
You can replace these with such code:
$backordered_items = false;
$config = hikashop_config();
$group = $config->get('group_options', 0);
foreach($order->products as $i => $row){
if(empty($row->cart_product_quantity)) continue;
if($group && $row->cart_product_option_parent_id) continue;
if($row->advance_orders !== 'NA') $backordered_items = true;
}
foreach($local_usable_rates as $k => $rate){
$rate->shipping_params->group_package = $backordered_items;
Please Log in or Create an account to join the conversation.
with this
Then I did as you said
In both, you'll find that line:
foreach($local_usable_rates as $k => $rate){
in the function onShippingDisplay of the plugins main file plugins/hikashopshipping/fedex/fedex.php and plugins/hikashopshipping/ups/ups.php
You can replace these with such code:
$backordered_items = false;
$config = hikashop_config();
$group = $config->get('group_options', 0);
foreach($order->products as $i => $row){
if(empty($row->cart_product_quantity)) continue;
if($group && $row->cart_product_option_parent_id) continue;
if($row->advance_orders !== 'NA') $backordered_items = true;
}
foreach($local_usable_rates as $k => $rate){
$rate->shipping_params->group_package = $backordered_items;
I just change the code to use to
For UPS it works great. When someone chooses send instead of hold the shipping is almost double. For Fedex however, I'm not seeing any changes in the price whether it is set to hold or send. Is there a special way I have to setup the Fedex plugin to where the group packages will be set up right? Also about the Fedex plugin, I had a customer place an order yesterday and chose Fedex as their shipping method. When I went to Fedex to create the shipment, the service (Home Delivery) is not even available in their area. My question is if the service that the plugin is setup for is not available in that person's location why is it coming back with a shipping rate? Shouldn't it not even show up as an option? I've attached a screenshot of how I currently have it setup. One other question, is there a way to setup where custom item fields can be changed in the cart?
Please Log in or Create an account to join the conversation.
- Posts: 12953
- Thank you received: 1778
My question is if the service that the plugin is setup for is not available in that person's location why is it coming back with a shipping rate? Shouldn't it not even show up as an option? I've attached a screenshot of how I currently have it setup. One other question, is there a way to setup where custom item fields can be changed in the cart?
We don't have any control on the rate returned from the FedEx shipping platform, so if a shipping rate is returned then the shipping plugin will just display it. If you want to move the "Custom field" block through your checkout workflow, you'll have to do it through "Hikashop->System->Configuration->Checkout". If you want to edit the content of the field block you can edit the "Fields" file of the "Checkout" view of your front-end template.
Using your code customization should also do the job for the FedEx shipping method, so if you don't see any difference you should try it with your browser's cache cleared. If you still see no differences, then it probably means that the package size/weight restriction of a FedEx shipping package is too low to contain 2 of your products.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Posts: 12953
- Thank you received: 1778
$You'll probably find your order custom field value through the "$order->backordered_item" variable, and then you'll probably just need these lines :
Note that it will be good if you could check the content of your $order variable by using a var_dump for example.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Posts: 12953
- Thank you received: 1778
My bad, "Order" custom fields are stocked in the session until the order is created, so you should retrieve it using that kind of code :
Please Log in or Create an account to join the conversation.
It works, but the only thing I see wrong is that whatever value is selected the first time is the way it will stay no matter what you select after that. What I mean is when someone comes to the cart and they choose to hold the order until all items are in stock. They then go to the next step and it gives a shipping rate. If they change their mind and decide to go back to the beginning of the cart and choose send the items that are in stock now when they go to the next step it still shows the shipping rate for if they chose to hold the order. I'm guessing this is because it is stored in the session. Is there a way to reset the variable if they go back to the beginning of the cart?
Please Log in or Create an account to join the conversation.
- Posts: 12953
- Thank you received: 1778
If you don't want to use the shipping cache, you'll probably find your solution via :
www.hikashop.com/forum/4-how-to/81210-de...html?start=40#207977
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Posts: 12953
- Thank you received: 1778
It's probably coming from dimensions limitation on the code of the FedEx plugin and which are based on the box limitations that we can find through the FedEx documentation.
Can you tell me the dimensions of the products that are on your cart when you test it ?
Thanks.
Please Log in or Create an account to join the conversation.
-4.375 inches long X 2.625 inches wide X 1.875 inches tall
For the Fedex plugin I have the "box dimensions" set as 12 inches long X 12 inches wide X 6 inches tall and I have the "use box dimensions" checked. I thought it may have something to do with these settings, but I don't know.
Please Log in or Create an account to join the conversation.
- Posts: 12953
- Thank you received: 1778
Can you test it without the "Box dimensions" option and unset the "Use box dimensions" ?
Thanks.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Posts: 12953
- Thank you received: 1778
I just checked the FedEx code and in your case the problem is coming from the fact that FedEx limitations are actually too big for your product, here is the limitation of the FedEx Ground service for example :
With FedEx Ground®
services, you can ship packages
up to 150 lbs.; up to 108" in length and 165" in length
plus girth.
We don't have any control on what is returned from the FedEx shipping platform and at this point the solution will probably be to change the FedEx shipping plugin :
- Dimension/Weight limits
- Way of grouping your product and sending it to the FedEx platform.
But doing it isn't recommended unless you change the dimension limitation to smaller one.
Please Log in or Create an account to join the conversation.