تابع ووکامرسی meta_is_product_attribute اینکه نام داده شده عضو ویژگی محصول باشد

تابع ووکامرسی meta_is_product_attribute اینکه نام داده شده عضو ویژگی محصول باشد

تابع ووکامرسی meta_is_product_attribute – اینکه نام داده شده عضو ویژگی محصول باشد

Syntax – سینتکس

meta_is_product_attribute( (string) $name, (string) $value, (int) $product_id ); 

Parameters – پارامتر ها (3)

  • 1- $name (string)
  • 2- $value (string)
  • 3- $product_id (int)

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

if ( !function_exists( 'meta_is_product_attribute' ) ) { 
    require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-conditional-functions.php'; 
} 
  
// of the attribute 
$name = ''; 
  
// The value. 
$value = ''; 
  
// The product id. 
$product_id = -1; 
  
// NOTICE! Understand what this does before running. 
$result = meta_is_product_attribute($name, $value, $product_id); 
    

Defined – محل تعریف

/includes/wc-conditional-functions.php

function meta_is_product_attribute( $name, $value, $product_id ) { 
    $product = wc_get_product( $product_id ); 
 
    if ( $product && method_exists( $product, 'get_variation_attributes' ) ) { 
        $variation_attributes = $product->get_variation_attributes(); 
        $attributes = $product->get_attributes(); 
        return ( in_array( $name, array_keys( $attributes ) ) && in_array( $value, $variation_attributes[ $attributes[ $name ]['name'] ] ) ); 
    } else { 
        return false; 
    } 
} 

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