/* PUBLIC API FINAL SYNC WITH LOGGING */ function send_stock_update_to_public_dodonipbl($product_id) { $product = wc_get_product($product_id); if (!$product) return; $ean = get_post_meta($product_id, 'isbn-13', true); if (empty($ean)) { $ean = $product->get_sku(); } $ean = preg_replace('/[^0-9]/', '', $ean); if (empty($ean)) return; $is_available = $product->is_in_stock(); $avail_text = $is_available ? 'True' : 'False'; $response = wp_remote_post('https://marketplace-external-api.public.gr/api/v1/offers/update-price-stock', array( 'headers' => array( 'Content-Type' => 'application/json', 'Authorization' => 'Bearer 0d32f506-896f-40e3-9831-29007e056d62', ), 'body' => json_encode(array(array( 'materialEan' => $ean, 'supplierId' => 'DODONIPBL', 'price' => (float)$product->get_price(), 'promiseDays' => 1, 'available' => $is_available ))), 'timeout' => 15, )); // ΑΥΤΟ ΘΑ ΓΡΑΦΕΙ ΣΤΟ LOG ΓΙΑ ΝΑ ΤΟ ΒΛΕΠΕΙΣ $log_file = WP_CONTENT_DIR . '/public-stock-sync.log'; $status = is_wp_error($response) ? 'ERR' : wp_remote_retrieve_response_code($response); $log_entry = "[" . date('Y-m-d H:i:s') . "] NEW SYNC: EAN $ean | Avail $avail_text | Status $status\n"; file_put_contents($log_file, $log_entry, FILE_APPEND); } add_action('admin_init', function() { if (isset($_GET['run_public_bulk_sync']) && $_GET['run_public_bulk_sync'] == '1') { $offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0; $args = array( 'post_type' => 'product', 'posts_per_page' => 10, 'offset' => $offset, 'post_status' => 'publish', 'meta_query' => array( 'relation' => 'OR', array('key' => 'publisher', 'value' => '', 'compare' => '='), array('key' => 'publisher', 'compare' => 'NOT EXISTS') ) ); $products = get_posts($args); if (empty($products)) { wp_die("
Ελέγξτε το log αρχείο για επιβεβαίωση.
This XML sitemap is used by search engines which follow the XML sitemap standard. This file contains links to sub-sitemaps, follow them to see the actual sitemap content.
This file was dynamically generated using the WordPress content management system and XML Sitemap Generator for Google by Auctollo.