Untitled

 avatar
unknown
plain_text
a year ago
2.3 kB
13
Indexable
add_action('marketking_extend_page', function($pageid){
    ?>
    <div id="marketking_footer_hidden">
        <?php
        wp_footer();
        ?>
    </div>
    <?php
});
add_filter('marketking_css_queue', function($q){
    $new_items = array('acf-global','acf-input','acf-pro-input','acf-datepicker','acf-timepicker','tinymce','tinymce-root');
    $q = array_merge($q, $new_items);
    return $q;
}, 10, 1);
add_filter('marketking_js_queue', function($q){
    $new_items = array('acf-global','acf-input','acf-pro-input','acf-datepicker','acf-timepicker','acf-color-picker-alpha','tinymce','tinymce-root');
    $q = array_merge($q, $new_items);
    return $q;
}, 10, 1);
add_action('marketking_after_save_product', function($product_id, $vendor_id){
    do_action( 'acf/save_post', $product_id );

    $select_location = get_field('select_location', $product_id);
    if ($select_location) {
        update_user_meta(get_current_user_id(), 'select_location', $select_location);
    }

}, 10, 2);
add_action( 'marketking_edit_product_after_tags', function($post){
    acf_form_head();
    ?>
    <div class="col-xxl-12 col-md-12 marketking_card_gal_cat_tags" style="background: white; padding:20px;border-radius: 4px;">
        <?php
            $product_id = $post->ID;

            $user_id = get_current_user_id();
            $previous_select_location = get_user_meta($user_id, 'select_location', true);

            // Set the default value if it exists
            if ($previous_select_location) {
                add_filter('acf/load_value/name=select_location', function($value, $post_id, $field) use ($previous_select_location) {
                    return $previous_select_location;
                }, 10, 3);
            }

            acf_form(array(
                'fields' => array('select_location'),
                'form' => false,
                'post_id' => $product_id,
            )); 
        ?>
    </div>
    <?php
});
add_action('woocommerce_product_meta_end', function(){
    global $post;
    $product_id = $post->ID;
    // get product or vendor value
    $location  = get_field('select_location');
    if (!empty($location)){
        // try to get value from vendor
    }
    if (!empty($location)){
        echo '<br>Location: <strong>'.$location.'</strong>';
    }
}, 1000, 1);
Editor is loading...
Leave a Comment