MultivendorX
-
AuthorPosts
-
-
June 4, 2024 at 10:02 PM #220420l.ganParticipant
Hello
Thanks for the great plugin support.
Could you help me. According to the law in my country, I must provide labeling codes for each item on the receipt.i.e. Before the order reaches the “Completed” status (at this point the final receipt is generated), the supplier must enter labeling codes for the goods that will be shipped to the client (dashboard – vendor-orders – order).I found a solution to add codes to the order from the administrator side. This code works and is compatible with HPOS. But I can’t figure out how to add these fields to an order from the supplier’s side.
I need the supplier to be able to enter marking codes for each item in the order from the moment the order is “in process” to “completed”. Please, help.
// Add a custom field add_action( 'woocommerce_before_order_itemmeta', 'add_order_item_custom_field', 10, 2 ); function add_order_item_custom_field( $item_id, $item ) { // Targeting line items type only if( $item->get_type() !== 'line_item' ) return; $post_key = 'cfield_oitem_'.$item_id; woocommerce_wp_text_input( array( 'id' => $post_key, 'label' => __( 'Custom Text Field Title', 'text_domain' ), 'description' => __( 'Enter the title of your custom text field.', 'text_domain' ), 'desc_tip' => true, 'class' => 'woocommerce', 'value' => $item->get_meta('_custom_field'), ) ); } // Save the custom field value (Compatible with HPOS) add_action('woocommerce_before_save_order_item', 'save_order_item_custom_field_value', 100 ); function save_order_item_custom_field_value( $item ){ $post_key = 'cfield_oitem_'.$item->get_id(); if( isset($_POST[$post_key]) ) { $item->update_meta_data( '_custom_field', sanitize_text_field($_POST[$post_key]) ); } } add_filter('woocommerce_order_item_display_meta_key', 'filter_wc_order_item_display_meta_key', 20, 3 ); function filter_wc_order_item_display_meta_key( $display_key, $meta, $item ) { // Change displayed label for specific order item meta key if( is_admin() && $item->get_type() === 'line_item' && $meta->key === '_custom_field' ) { $display_key = __("Some label", "woocommerce" ); } return $display_key; }
Copycode source: https://stackoverflow.com/a/54406630/18203998
Copy -
June 5, 2024 at 11:00 AM #220429Sangita Support SquadKeymaster
@l.gan, We understand your end. But at this time, we’re unable to accommodate your custom request due to limited bandwidth.
If it were a quick customization that requires a few lines of coding help,we’d happily assist within our free support window. However, the complexity of your request exceeds our current support capabilities.
Now if you need guidance with the hook/filter please do let us know, we will surely assist you accordingly.Alternatively you may reach out to our service team here :https://multivendorx.com/custom-development/ for assistance with your custom requirement. You can also send them a mail on custom.dev@multivendorx.com.
Thanks for your understanding and let us know if you need any further assistance from our end.
-
June 5, 2024 at 6:34 PM #220446Sangita Support SquadKeymaster
Thanks for getting back to us. Our team is looking into this. We will provide you with the hook/filter accordingly. Kindly provide us some time.
-
June 5, 2024 at 9:01 PM #220455l.ganParticipant
I displayed custom_field in the order meta, at least the ability to enter it. but I don’t understand how I can save it?
add_action( 'mvx_vendor_dash_after_order_itemmeta_table', 'mvx_add_custom_field_to_vendor_order_item', 10, 3 ); function mvx_add_custom_field_to_vendor_order_item( $item_id, $item, $product ) { $post_key = 'cfield_oitem_' . $item_id; $custom_field = get_post_meta($item->get_id(), '_custom_field', true); ?> <input type="text" name="<?php echo $post_key; ?>" class="form-control" value="<?php echo $custom_field; ?>" > <?php }
Copy
-
-
June 5, 2024 at 9:32 PM #220456Sangita Support SquadKeymaster
Can you please let us know exactly what flow are you trying to achieve on your end so that we can assist you further.
-
June 6, 2024 at 11:14 AM #220468Sangita Support SquadKeymaster
Hello @l.gan, It looks like you’re trying to implement a custom flow. To be honest, providing a solution for this custom flow exceeds the capabilities of our free support.
If you want assistance with your custom work, you may reach out to our custom team at custom.dev@multivendorx.com and they will assist you there accordingly.
However, please let us know exactly where you want to add the custom field, and we can provide you with the appropriate hook or filter to help you add it.
Thanks for your understanding. . -
July 10, 2024 at 9:06 PM #221558steven-6784Participant
Hello,
I’m also having trouble with saving a custom field. Whilst the code to add the field is supplied by MVx, the code to save it is not.
Were you able to resolve your issue? If so could you let others know how you resolved it? Thank you! -
July 10, 2024 at 9:56 PM #221561Sangita Support SquadKeymaster
Hello there, Kindly follow the code given here https://multivendorx.com/docs/code-snippet/add-new-tab-in-add-product-page/ for the custom code to add a custom field in the vendor dashboard.
Now currently we do not have any readymade custom code for saving the custom field. Kindly provide our team some time to get back to you with the code to save the field data. Please note as our team is currently preoccupied with their preassigned work hence it might take us some time to get back to you with the custom code.
Thanks for your understanding.-
July 13, 2024 at 12:23 AM #221613l.ganParticipant
Thank you for your help and for coming back to discuss this issue.
The code you shared adds a custom tab and field to a single product page.And we need to add it to the order, to the meta of each product.
For example, if we sold 3 pairs of boots in an order, then we must add a field to each pair. And the value of this field should be different, because this is a product label. Each product has its own labeling, which can be assigned only after it is understood which product is packaged for shipment.
-
-
July 13, 2024 at 4:38 PM #221619Sangita Support SquadKeymaster
Hello @l.gan, Yes, you are absolutely right that the earlier shared code was for adding a custom field on the edit product page in the vendor dashboard. We shared that code in response to queries from other users.
For your required flow, we do not have any ready-made code available. Implementing your required flow involves substantial coding support, which is beyond our free support capabilities.
If you need assistance with the required hook/filter, please let us know. Alternatively, you can hire our service team from here: https://multivendorx.com/custom-development/. They will assist you in implementing your required flow.
Let us know if you need any further assistance from our end.
-
September 13, 2024 at 12:45 PM #235251Sangita Support SquadKeymaster
It’s been long and we have not heard back from you. We presume your query is resolved now. We are closing this thread. If you need help or face issue in future please do create a new support ticket.
-
-
AuthorPosts
The topic ‘Save custom order item field on Woocommerce admin order pages + Vendor Dashboard’ is closed to new replies.