jpussacq
Forum Replies Created
-
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(); } } } } }
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(); } } } }
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.
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, 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 … ??
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, 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.
Forum: Plugins
In reply to: [Really Simple CAPTCHA] Captcha code error traslationIt works perfect. I really appreciate your quick response. In my case, I modified functions.php adding:
add_filter ('wpcf7_use_really_simple_captcha', '__return_true');
Forum: Plugins
In reply to: [Really Simple CAPTCHA] Captcha code error traslationHi aledef. Exactly the same problem (spanish version)
Forum: Plugins
In reply to: [Really Simple CAPTCHA] Captcha code error traslationI am having this problem with:
– Really Simple CAPTCHA 1.9
– Contact Form 7 4.4.2
The message to translate is “Your entered code is incorrect.”Forum: Plugins
In reply to: [Twit Connect] [Plugin: Twit Connect] User changed his username on TwitterI have documented my workaround here: https://viviendoenlaeradelaweb20.blogspot.com.ar/2012/07/problema-con-twit-connect-en-buddypress.html
Forum: Plugins
In reply to: [Twit Connect] [Plugin: Twit Connect] User changed his username on TwitterI think I found the problem and solution.
The cause is that a user changes their nickname on Twitter.com.
The consequence is that do not work: private messages and tagging (mentions).
The diagnosis is that they are distinct: nicename and login.
The way to found it is:
SELECT *
FROM
wp_users
User_loginWHERE
<>user_nicename
The workaround is to update the nicename to make it equal to login.
Swhitley: I would like your opinion on this approach to solution. Am I doing the right thing?
Thanks!
Forum: Plugins
In reply to: [Twit Connect] [Plugin: Twit Connect] User changed his username on TwitterHello Swhitley. Thank you very much for answering ??
Are there any additional information that can give you to find the cause of the problem? Any help is welcome. I am available to help with whatever it takes!
Thanks!