تابع wc_update_220_variations بروزرسانی ویژگی های متغیر ووکامرس به نسخه 2.2.0
تابع ووکامرسی wc_update_220_variations – بروزرسانی ویژگی های متغیر ووکامرس به نسخه 2.2.0
Syntax – سینتکس
wc_update_220_variations();
Usage – نحوه استفاده
if ( !function_exists( 'wc_update_220_variations' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-update-functions.php'; } // NOTICE! Understand what this does before running. $result = wc_update_220_variations();
Defined – محل تعریف
/includes/wc-update-functions.php
function wc_update_220_variations() { global $wpdb; // Update variations which manage stock $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' LEFT OUTER JOIN {$wpdb->postmeta} as postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = '_manage_stock' WHERE posts.post_type = 'product_variation' AND postmeta.meta_value IS NOT NULL AND postmeta.meta_value != '' AND postmeta2.meta_value IS NULL " ); foreach ( $update_variations as $variation ) { $parent_backorders = get_post_meta( $variation->variation_parent, '_backorders', true ); add_post_meta( $variation->variation_id, '_manage_stock', 'yes', true ); add_post_meta( $variation->variation_id, '_backorders', $parent_backorders ? $parent_backorders : 'no', true ); } }
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر