Обновите акции единого продукта в WooCommerce с использованием API от import.ioPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Обновите акции единого продукта в WooCommerce с использованием API от import.io

Сообщение Anonymous »

У меня есть проблема. < /p>

Я пытаюсь использовать API из import.io для автоматического управления запасом продуктов, которые я перепродаю. Origin Shop. /> После проверки того, какая группа является продуктом, он получает данные, поэтому я могу обновить запасы. Предложения? < /p>

Спасибо! < /p>

$userGuid = "c5ed744c-7c10-46d1-9c43-22c6eef5aaca";
$apiKey = "private";

// Issues a query request to import.io
function query($connectorGuid, $input, $userGuid, $apiKey) {

$url = "https://query.import.io/store/connector/" . $connectorGuid . "/_query?_user=" . urlencode($userGuid) . "&_apikey=" . urlencode($apiKey);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"import-io-client: import.io PHP client",
"import-io-client-version: 2.0.0"
));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array("input" => $input)));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
curl_close($ch);

return json_decode($result);
}
//This is a custom field
$url_font = apply_filters('custom_url_font', get_post_meta($post->ID, '_url_font', true));

add_action('woocommerce_before_shop_loop_item_title','category_stock');

function category_stock() {

global $woocommerce,$product, $post;
$post_id = $post->ID;
$groupcat = 608; // category id for the this api
$terms = get_the_terms( $post_id, 'product_cat' ); //get taxonamy of the products

if ( $terms && ! is_wp_error( $terms ) ) :
foreach ( $terms as $term ) {
$catid = $term->term_id;
if($groupcat == $catid) {
$result = query("d9df1137-b402-40ef-b472-35db84684fbe", array(
"webpage/url" => $url_font,//this is the url from the custom field
), $userGuid, $apiKey, false);
if(($result->results[0]->stock)=="INSTOCK")
{
update_post_meta($post->ID, '_stock', '10');
}
else{
update_post_meta($post->ID, '_stock', '0');
}
}
}endif;
}


Подробнее здесь: https://stackoverflow.com/questions/343 ... -import-io
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»