У меня есть проблема. < /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
Обновите акции единого продукта в WooCommerce с использованием API от import.io ⇐ Php
Кемеровские программисты php общаются здесь
1747382042
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;
}
Подробнее здесь: [url]https://stackoverflow.com/questions/34386102/update-single-product-stock-in-woocommerce-using-api-from-import-io[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия