У меня есть атрибут «Цвет», и он имеет два атрибута «Красный» и «Зеленый».
Когда я запускаю это с использованием WC REST APIWC REST API | Атрибуты не загружаются
Все работает из приведенного ниже кода, я застрял в атрибутах.
print_r($client->products->create(array(
'title' => 'Nile - Over Counter Basin',
'sku' => '91081_Nile',
'type' => 'simple',
'regular_price' => '7260',
'sale_price' => '5445',
'description' => 'Nile - Over Counter BasinOver Counter BasinHindware Italian CollectionContemporary design with smooth flowing line Space for toiletries',
'dimensions'=>array('length' =>'67.5' ,'width' =>'39.5','height'=>'12.5'),
'categories'=>array(' SANITARYWARE' =>'592',' WASHBASIN' =>'650',' Table Top Wash Basin' =>'508'),
'images' =>Array ('91081_Nile'=>Array('src'=>'http://www.somethingsomething.com/images/products/91081/2.jpg','title'=>'91081_Nile','position'=>'0')),
'short_description'=>'Contemporary design with smooth flowing line Space for toiletries <table id="ProductDescriptiontable"><tr><td>Brand</td><td>:</td><td class="thirdcolumn">Hindware</td></tr><tr><td>Product Name</td><td>:</td><td class="thirdcolumn">Nile - Over Counter Basin</td></tr><tr><td>Product Description</td><td>:</td><td class="thirdcolumn">Table Top Wash Basin</td></tr></tr><tr><td>Product Color</td><td>:</td><td class="thirdcolumn">StarwhiteIvory</td></tr></table>',
'attributes' => Array ('name'=>'Color','slug'=>'color','position'=>'0','visible'=>'true','options'=>'Red'),
'enable_html_short_description' => true, // This is the line you need to add
) )) ;
Ананд: После добавления атрибутов в множественном массиве, атрибуты отображаются в правильном разделе, но они не рассматривается как атрибуты, .. смотрите изображение, они рассматриваются как обычный текст и а не как атрибуты.
Мой код:
'attributes'=>array(array('name'=>'Color','Slug'=>'color','position'=>'0','visible'=>true,'options'=>'Starwhite'),array('name'=>'Model',
'Slug'=>'model','position'=>'0','visible'=>true,'options'=>'Pedestal Wash Basin'),array('name'=>'Brands','Slug'=>'brands','position'=>'0','visible'=>true,'options'=>'Hindware'),array('name'=>'Washbasin Size','Slug'=>'washbasin-size','position'=>'0','visible'=>true,'options'=>'56 x 46 x 38.5 cm'),array('name'=>'Washbasin Type','Slug'=>'washbasin-type','position'=>'0','visible'=>true,'options'=>'Washbasin With Pedestal'))
Еще раз спасибо, миллион, это сработало. Многие люди предложили изменить версию API .. но это решило мою проблему. –
как я могу изменить ваше решение, если у меня есть несколько атрибутов для одних и тех же продуктов, они попадут под несколько массивов? или одиночный Арри? можете ли вы привести пример ниже? Множество атрибутов: (Цвет: белый, красный) (модель: настенный) (Tank: Ceramic) –
Вам необходимо передать несколько элементов массива, например, '' attributes '=> array (array (' name '=>' color '....), array (' name '=>' model '.....)) ' –