Wholesale prices in backend – Editing orders
-
Good Morning. I would like to know if there is any way to view the wholesale prices at the time of editing an order through the backend. I speak of this functionality: https://docs.woocommerce.com/document/managing-orders/#section-2
In case it is not possible, I ask for help or recommendation.
1) Do you plan to add this feature in the future?
2) Could you tell me how I can solve it? Some tip?
From already thank you very much.
-
Hi @jpussacq,
At the moment we don’t support backend order editing because of the way WooCommerce have constructed the backend interface this is actually quite tricky to do programmatically.
There is a great workaround for this though. Here is a guide to help:
https://wholesalesuiteplugin.com/kb/can-order-behalf-wholesale-customers/
When you pair this solution with our Order Form plugin it is actually quite quick and quick enough if you are doing phone orders even.
Hope this helps!
Hi, Josh. First of all thank you for your quick response.
I’m not sure if I understand the alternative solution. I need to use the order modification in the backend. If I install the plugin “User Switching plugin by John Blackbourn”, I understand that I can log in on behalf of another user. But if that user does not have administration permissions, can I modify it in the backend?
Of course I appreciate if you can explain how the user permissions would work.
Hi @jpussacq,
No worries. Once an order is completed I believe you can’t modify it. You can only alter orders if they’re in Pending Payment from what I understand.
I just assume you were looking to place orders on behalf of your customers? Is this correct?
Unfortunately, since we can’t modify the pricing in the backend the wholesale pricing is not available so you would need to lookup and specify the pricing as an override.
If you’re just looking to place orders on behalf of the customer then doing it on the front end is much more preferable. You create the customer’s account (if they don’t have one already), switch to them using the User Switching plugin and then place the order for them. This will also then mark the order as a wholesale order in the order’s meta.
Hope this makes sense! Let me know if I’m understanding correctly or not.
Hello Josh again. Actually I need to modify the pending orders from the backend. For example, adding products. The problem is that it takes me the standard price and not the wholesale price. I understand that your plugin currently does not handle this feature. Can you think of any way to do it? Maybe you can guide me on where to add custom code. The option to enter on behalf of another user does not work, because I understand that it does not allow to enter the backend since the user is not an administrator. Thanks since now!
Hi @jpussacq,
Unfortunately, the only way to attack this problem on the backend would be to edit the item on the order and override the price. You’ll need to open up the product in another tab and grab the info from there I think.
Sorry I don’t have a better workaround for you!
-
This reply was modified 7 years, 2 months ago by
Josh Kohlbach. Reason: clarifying its the item on the order
Hi, Josh. Thanks for the reply. We are thinking with my client that the solution in this case would be to install two sites. One for wholesalers. And another for common clients. It seems a drastic little, but we can not think of another alternative. I appreciate the support you have given us. I thought maybe there was a WordPress filter to overwrite the price in the backend … ??
Josh. I am trying somethink like that. Works great except to obtain the customer role. What do you think?
function precio_mayorista_backend_edicion_orden($price, $product) { $roleKey = "wholesale_customer"; if ( !is_admin() || ( is_admin() && is_post_type_archive() ) ) return $price; global $post, $woocommerce; $order = new WC_Order( $post_id ); $user_id = $order->user_id; $user = get_user_by('id', $user_id); if ( in_array( $roleKey, (array) $user->roles ) ) { $wholesalePrice = get_post_meta( $product->id , $roleKey . '_wholesale_price' , true ); return $wholesalePrice; } else { return $price; } } add_filter('woocommerce_get_price', 'precio_mayorista_backend_edicion_orden', 10, 2);
-
This reply was modified 7 years, 2 months ago by
jpussacq.
Hi @jpussacq,
I think you might have an error, is it fetching the order ok?
Where did $post_id come from? I can’t see that being instantiated anywhere.
Let me know if you have any joy. We may be able to integrate an approach like this in the future but there is a LOT more to pricing than just fetching the price I’m afraid in a real life scenario. We have multiple levels, quantity based pricing and much more to consider.
Hope this might serve as a work around for your project though ??
Hi, Josh. I think you’re right. I can not access the order number from here. Can you think of another filter or action? I need something simple that allows the administrator to change to the wholesale price. But for this you must check beforehand if the customer of the order has the role wholesale_customer. Thank you.
Hi Josh. I found a solution. I would be interested to know your opinion. Thank you.
add_action( 'woocommerce_order_item_add_action_buttons', 'action_aplicar_mayoristas', 10, 1); function action_aplicar_mayoristas( $order ) { echo '<button type="button" onclick="document.post.submit();" class="button button-primary generate-items">Aplicar precios mayoristas</button>'; echo '<input type="hidden" value="1" name="aplicar_mayoristas" />'; }; add_action('save_post', 'aplicar_mayoristas', 10, 3); function aplicar_mayoristas($post_id, $post, $update){ $slug = 'shop_order'; $roleKey = "wholesale_customer"; if(is_admin()){ if ( $slug != $post->post_type ) { return; } if(isset($_POST['aplicar_mayoristas']) && $_POST['aplicar_mayoristas']){ $order = wc_get_order( $post_id); foreach ($order->get_items() as $item_id => $item ) { $wholesalePrice = get_post_meta( $item->get_product_id() , $roleKey . '_wholesale_price' , true ); $item->set_subtotal($wholesalePrice); $item->set_total($wholesalePrice); $item->save(); } } } }
Updated, I forgot quantity:
add_action( 'woocommerce_order_item_add_action_buttons', 'action_aplicar_mayoristas', 10, 1); function action_aplicar_mayoristas( $order ) { echo '<button type="button" onclick="document.post.submit();" class="button button-primary generate-items">Aplicar precios mayoristas</button>'; echo '<input type="hidden" value="1" name="aplicar_mayoristas" />'; }; add_action('save_post', 'aplicar_mayoristas', 10, 3); function aplicar_mayoristas($post_id, $post, $update){ $slug = 'shop_order'; $roleKey = "wholesale_customer"; if(is_admin()){ if ( $slug != $post->post_type ) { return; } if(isset($_POST['aplicar_mayoristas']) && $_POST['aplicar_mayoristas']){ $order = wc_get_order( $post_id); foreach ($order->get_items() as $item_id => $item ) { if ( !wc_get_order_item_meta( $item->get_id() , '_wwp_wholesale_priced', true) ) { $wholesalePrice = get_post_meta( $item->get_product_id() , $roleKey . '_wholesale_price' , true ); $item->set_subtotal( $wholesalePrice * $item->get_quantity() ); $item->set_total( $wholesalePrice * $item->get_quantity() ); $item->save(); } } } } }
-
This reply was modified 7 years, 2 months ago by
- The topic ‘Wholesale prices in backend – Editing orders’ is closed to new replies.