wc_update_300_grouped_products بروزرسانی کالا گروه شده ووکامرس نسخه 3.0.0
تابع ووکامرسی wc_update_300_grouped_products – بروزرسانی محصولات گروه شده ووکامرس به نسخه 3.0.0
Syntax – سینتکس
wc_update_300_grouped_products();
Usage – نحوه استفاده
if ( !function_exists( 'wc_update_300_grouped_products' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-update-functions.php'; } // NOTICE! Understand what this does before running. $result = wc_update_300_grouped_products();
Defined – محل تعریف
/includes/wc-update-functions.php
function wc_update_300_grouped_products() { global $wpdb; $parents = $wpdb->get_col( "SELECT DISTINCT( post_parent ) FROM {$wpdb->posts} WHERE post_parent > 0 AND post_type = 'product';" ); foreach ( $parents as $parent_id ) { $parent = wc_get_product( $parent_id ); if ( $parent && $parent->is_type( 'grouped' ) ) { $children_ids = get_posts( array( 'post_parent' => $parent_id, 'posts_per_page' => -1, 'post_type' => 'product', 'fields' => 'ids', ) ); update_post_meta( $parent_id, '_children', $children_ids ); // Update children to remove the parent. $wpdb->update( $wpdb->posts, array( 'post_parent' => 0, ), array( 'post_parent' => $parent_id, ) ); } } }
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر