Код: Выделить всё
$customAttributes = array();
$attributes = $product->get_attributes();
foreach($attributes as $attr=>$attr_deets){
$attribute_label = wc_attribute_label($attr);
if ( isset( $attributes[ $attr ] ) || isset( $attributes[ 'pa_' . $attr ] ) ) {
$attribute = isset( $attributes[ $attr ] ) ? $attributes[ $attr ] : $attributes[ 'pa_' . $attr ];
if ( $attribute['is_taxonomy'] ) {
array_push($customAttributes, array(
$attribute_label => implode( ', ', wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) ) )
));
} else {
array_push($customAttributes, array(
$attribute_label => $attribute['value']
));
}
}
}
Код: Выделить всё
{
"att-1": "value 1 | value 2"
},
{
"att-2": "value 1 | value 2"
}
Код: Выделить всё
{
"type": "att-1",
"value": "value 1",
"value": "value 2"
},
{
"type": "att-2",
"value": "value 1",
"value": "value 2",
},
Я пытался изменить его, но не могу понять, как заставить его работать так, как требуется.
Спасибо за помощь и ждем решения от профессионалов.
Ахмад
- Начинающий разработчик WP
Подробнее здесь: https://stackoverflow.com/questions/741 ... oocommerce
Мобильная версия