تابع wc_update_241_variations بروزرسانی ویژگی های متغیر ووکامرس به نسخه 2.4.1

تابع wc_update_241_variations بروزرسانی ویژگی های متغیر ووکامرس به نسخه 2.4.1

تابع ووکامرسی wc_update_241_variations – بروزرسانی ویژگی های متغیر ووکامرس به نسخه 2.4.1

Syntax – سینتکس

wc_update_241_variations(); 

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

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

Defined – محل تعریف

/includes/wc-update-functions.php

function wc_update_241_variations() { 
    global $wpdb; 
 
    // Select variations that don't have any _stock_status implemented on WooCommerce 2.2 
    $update_variations = $wpdb->get_results( " 
        SELECT DISTINCT posts.ID AS variation_id, posts.post_parent AS variation_parent 
        FROM {$wpdb->posts} as posts 
        LEFT OUTER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id AND postmeta.meta_key = '_stock_status' 
        WHERE posts.post_type = 'product_variation' 
        AND postmeta.meta_value IS NULL 
    " ); 
 
    foreach ( $update_variations as $variation ) { 
        // Get the parent _stock_status 
        $parent_stock_status = get_post_meta( $variation->variation_parent, '_stock_status', true ); 
 
        // Set the _stock_status 
        add_post_meta( $variation->variation_id, '_stock_status', $parent_stock_status ? $parent_stock_status : 'instock', true ); 
 
        // Delete old product children array 
        delete_transient( 'wc_product_children_' . $variation->variation_parent ); 
    } 
 
    // Invalidate old transients such as wc_var_price 
    WC_Cache_Helper::get_transient_version( 'product', true ); 
} 

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