Can you recommend new hooks?
-
Hello
Could you please tell me about new hooks/methods for adding custom fields to the dashboard after updating MultivendorX from 5.0 and above?
Our code worked fine before:
<?php
function art_woo_add_mark_codes() {
global $product, $post;
echo '<div class="options_group">';
woocommerce_wp_text_input(
[
'id' => '_declarax',
'label' => __( 'text', 'woocommerce' ),
'placeholder' => 'https://...',
'desc_tip' => 'true',
'description' => __( 'add site', 'woocommerce' ),
]
);
echo '</div>';
}
add_action( 'woocommerce_product_options_general_product_data', 'art_woo_add_mark_codes' );
add_action( 'woocommerce_process_product_meta', 'art_woo_mark_codes_save', 10 );
function art_woo_mark_codes_save( $post_id ) {
if ( isset( $_POST['_declarax'] ) ) {
update_post_meta( $post_id, '_declarax', esc_url_raw( $_POST['_declarax'] ) );
}
}
add_filter( 'mvx_product_data_tabs', 'add_custom_product_data_tabs_discr' );
function add_custom_product_data_tabs_discr( $tabs ) {
$tabs['pol-opi'] = array(
'label' => __( 'New TAb', 'your-text-domain' ),
'target' => 'custom_tab_product_data_discr',
'class' => array(),
'priority' => 97,
);
return $tabs;
}
add_action( 'mvx_product_tabs_content', 'add_custom_product_data_content_discr', 10, 3 );
function add_custom_product_data_content_discr( $pro_class_obj, $product, $post ) {
$declarax = get_post_meta( $product->get_id(), '_declarax', true );
?>
<div role="tabpanel" class="tab-pane fade" id="custom_tab_product_data_discr">
<div class="row-padding">
<div class="form-group">
<label class="control-label col-sm-3 col-md-3">
<?php esc_html_e( 'text', 'woocommerce' ); ?>
</label>
<div class="col-md-6 col-sm-9">
<input type="text" name="_declarax" class="form-control" value="<?php echo esc_attr( $declarax ); ?>" placeholder="https://">
</div>
</div>
</div>
</div>
<?php
}
add_action( 'mvx_process_product_object', 'save_custom_product_data_discr', 15, 4 );
function save_custom_product_data_discr( $product, $post_data ) {
if ( isset( $post_data['post_ID'] ) && isset( $post_data['_declarax'] ) ) {
update_post_meta( absint( $post_data['post_ID'] ), '_declarax', esc_url_raw( $post_data['_declarax'] ) );
}
}However, when migrating to the new version, we encountered the problem that our old product fields are no longer visible, editable, or saveable for vendors.
Please suggest new solutions.
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
You must be logged in to reply to this topic.