wc_update_300_product_visibility بروزرسانی قابلیت نمایش کالا ووکامرس نسخه 3.0.0

wc_update_300_product_visibility بروزرسانی قابلیت نمایش کالا ووکامرس نسخه 3.0.0

تابع ووکامرسی wc_update_300_product_visibility – بروزرسانی قابلیت نمایش محصول ووکامرس به نسخه 3.0.0

Syntax – سینتکس

wc_update_300_product_visibility(); 

Usage – نحوه استفاده

if ( !function_exists( 'wc_update_300_product_visibility' ) ) { 
    require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-update-functions.php'; 
} 
 
  
// NOTICE! Understand what this does before running. 
$result = wc_update_300_product_visibility(); 
    

Defined – محل تعریف

/includes/wc-update-functions.php

function wc_update_300_product_visibility() { 
    global $wpdb; 
 
    WC_Install::create_terms(); 
 
    if ( $featured_term = get_term_by( 'name', 'featured', 'product_visibility' ) ) { 
        $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_featured' AND meta_value = 'yes';", $featured_term->term_taxonomy_id ) ); 
    } 
 
    if ( $exclude_search_term = get_term_by( 'name', 'exclude-from-search', 'product_visibility' ) ) { 
        $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_visibility' AND meta_value IN ('hidden', 'catalog');", $exclude_search_term->term_taxonomy_id ) ); 
    } 
 
    if ( $exclude_catalog_term = get_term_by( 'name', 'exclude-from-catalog', 'product_visibility' ) ) { 
        $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_visibility' AND meta_value IN ('hidden', 'search');", $exclude_catalog_term->term_taxonomy_id ) ); 
    } 
 
    if ( $outofstock_term = get_term_by( 'name', 'outofstock', 'product_visibility' ) ) { 
        $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_stock_status' AND meta_value = 'outofstock';", $outofstock_term->term_taxonomy_id ) ); 
    } 
 
    if ( $rating_term = get_term_by( 'name', 'rated-1', 'product_visibility' ) ) { 
        $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_wc_average_rating' AND ROUND( meta_value ) = 1;", $rating_term->term_taxonomy_id ) ); 
    } 
 
    if ( $rating_term = get_term_by( 'name', 'rated-2', 'product_visibility' ) ) { 
        $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_wc_average_rating' AND ROUND( meta_value ) = 2;", $rating_term->term_taxonomy_id ) ); 
    } 
 
    if ( $rating_term = get_term_by( 'name', 'rated-3', 'product_visibility' ) ) { 
        $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_wc_average_rating' AND ROUND( meta_value ) = 3;", $rating_term->term_taxonomy_id ) ); 
    } 
 
    if ( $rating_term = get_term_by( 'name', 'rated-4', 'product_visibility' ) ) { 
        $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_wc_average_rating' AND ROUND( meta_value ) = 4;", $rating_term->term_taxonomy_id ) ); 
    } 
 
    if ( $rating_term = get_term_by( 'name', 'rated-5', 'product_visibility' ) ) { 
        $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_wc_average_rating' AND ROUND( meta_value ) = 5;", $rating_term->term_taxonomy_id ) ); 
    } 
} 

versions – نسخه ها

از نسخه : 3.0.2

نسخه فعلی : 3.0.6

دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2

ارسال نظر

جهت استفاده از کد حتما از تگ pre استفاده نمایید .

contact us

انجام انواع پروژه های وب


( فروشگاهی ، خبری ، رزرواسیون ، وردپرس ، حل مشکلات وردپرسی )

شماره تماس و واتساپ : 09398554859