Hi!! Great work with the api, Thanks so much!!
I think I have found some kind of bug in debugging mode, json response gets an undefined var error on Base.php line 435:
Helpers::debug("Base::apply_disconnector {$desc['name']} called from $called_from");
Apparently $desc['name'] is not defined:
Json returns: "json: Notice: Undefined index: name in /var/www/wordpress/wp-content/plugins/woocommerce-json-api-master/classes/WCAPI/Base.php on line 435 {"action":"woocommerce_json_api","proc":"set_products","arguments":{"tok....."
In my code I want to disconnect several categories from a product, if I comment the line 435 it works fine.
My code is:
<?php
error_reporting(E_ALL);
require_once "../wp-content/plugins/woocommerce-json-api-master/tests/functions.php";
include "../wp-content/plugins/woocommerce-json-api-master/tests/config.php";
///////////////////////////////////////////////////////
// Disconnecting Several Categories from a Product //
//////////////////////////////////////////////////////
Hi!! Great work with the api, Thanks so much!! I think I have found some kind of bug in debugging mode, json response gets an undefined var error on Base.php line 435: Helpers::debug("Base::apply_disconnector {$desc['name']} called from $called_from");
Apparently $desc['name'] is not defined:
Json returns: "json: Notice: Undefined index: name in /var/www/wordpress/wp-content/plugins/woocommerce-json-api-master/classes/WCAPI/Base.php on line 435 {"action":"woocommerce_json_api","proc":"set_products","arguments":{"tok....."
In my code I want to disconnect several categories from a product, if I comment the line 435 it works fine.
My code is:
<?php error_reporting(E_ALL);
require_once "../wp-content/plugins/woocommerce-json-api-master/tests/functions.php"; include "../wp-content/plugins/woocommerce-json-api-master/tests/config.php";
$skuDelProducto = "A498C3"; $categorias_a_eliminar = array(array("name" => "SomeCategory", "categoryPos" => -1), array("name" => "AnotherCategory", "categoryPos" => -1));
// STEP 1: Get available categories.
$data = array( 'action' => 'woocommerce_json_api', 'proc' => 'get_categories', 'arguments' => array( 'token' => $token, ) );
$json = curl_post($url,$data); $result = json_decode($json,true); $categories = $result['payload'];
for ($j=0; $j<sizeof($categorias_a_eliminar); $j++){ for ($i=0; $i<sizeof($categories); $i++){ if(strtolower($categories[$i]['name']) == strtolower($categorias_a_eliminar[$j]['name'])){ $categorias_a_eliminar[$j]['categoryPos'] = $i; } }
}
// STEP 2: Get the product
function get_products($args){ $data = array( 'action' => 'woocommerce_json_api', 'proc' => 'get_products', 'arguments' => array( 'token' => $args['token'], 'skus' => array( $args['sku'], 'DOESNTEXIST' ), 'include' => array( 'variations' => false, 'images' => false, 'featured_image' => false, 'reviews' => false, ), ) );
}
/////////////////////////////////////////////////////// // Disconnecting Several Categories from a Product // //////////////////////////////////////////////////////
$args = array('token' => $token, 'sku' => $skuDelProducto, 'url' => $url);
foreach($categorias_a_eliminar as $categoria_a_eliminar){ $products = get_products($args);
}