Changeset 3370412
- Timestamp:
- 09/30/2025 12:34:52 PM (6 months ago)
- Location:
- storecontrl-wp-connection/trunk
- Files:
-
- 4 edited
-
includes/api/class-storecontrl-web-api-functions.php (modified) (3 diffs)
-
includes/cronjob/class-storecontrl-cronjob-functions.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
storecontrl-wp-connection.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
storecontrl-wp-connection/trunk/includes/api/class-storecontrl-web-api-functions.php
r3350913 r3370412 67 67 $processed_products = ''; 68 68 $results = $web_api->storecontrl_get_sku_stock_changes(); 69 70 69 if (isset($results) && is_array($results) && !empty($results)) { 71 70 … … 479 478 $Product->set_gallery_image_ids($gallery_image_ids); 480 479 ftp_close($this::$storecontrl_ftp_connection); 480 481 do_action('storecontrl_after_gallery_save', $post_id, $gallery_image_ids); 481 482 } 482 483 } … … 1768 1769 { 1769 1770 global $wpdb; 1770 1771 1771 $logging = new StoreContrl_WP_Connection_Logging(); 1772 1772 1773 //removed limit 1 to form an array and loop through the array1774 1773 $existing_product_variation = $wpdb->get_results($wpdb->prepare(" 1775 SELECT *1776 FROM $wpdb->postmeta1777 WHERE meta_key = 'storecontrl_size_id' AND meta_value = '%s' 1778 ORDER BY meta_id DESC1779 ", $product_variation['sku_id']), 'ARRAY_A');1774 SELECT * 1775 FROM $wpdb->postmeta 1776 WHERE meta_key = 'storecontrl_size_id' AND meta_value = %s 1777 ORDER BY meta_id DESC 1778 ", $product_variation['sku_id']), ARRAY_A); 1780 1779 1781 1780 foreach ($existing_product_variation as $variation) { 1782 1781 1783 // Check if variation exist 1784 if (isset($variation['post_id']) && !empty($variation['post_id'])) { 1785 1786 $variation_post_id = $variation['post_id']; 1787 $product_id = wp_get_post_parent_id($variation_post_id); 1788 1789 $Variation = new WC_Product_Variation( $variation_post_id ); 1790 1791 if( isset($product_id) && is_int($product_id) ){ 1792 $Variation->set_parent_id($product_id); 1793 } 1794 else{ 1795 $logging->log_file_write('ERROR | Unkown parent product for varation: ' . $variation_post_id ); 1796 $wpdb->query($wpdb->prepare("DELETE * FROM $wpdb->postmeta WHERE meta_id = '%s'", $variation['meta_id']), 'ARRAY_A'); 1797 return; 1798 } 1799 1800 if(abs($product_variation['stock_total']) != $product_variation['stock_total']){ 1801 $product_variation['stock_total'] = 0; 1802 } 1803 $Variation->set_stock_quantity($product_variation['stock_total']); 1804 $Variation->set_manage_stock('yes'); 1805 1806 1807 $logging->log_file_write('StoreContrl | Update stock of variation: ' . $variation_post_id . ' / ' . $product_variation['sku_id']. ' with new stock total: ' .$product_variation['stock_total']); 1808 1809 // Remove sale dates from variation if zero stock otherwise it gets backorder status by WC 1810 if( $product_variation['stock_total'] == 0 ){ 1782 if (!empty($variation['post_id'])) { 1783 $variation_post_id = (int) $variation['post_id']; 1784 $product_id = (int) wp_get_post_parent_id($variation_post_id); 1785 1786 if ($product_id <= 0) { 1787 $logging->log_file_write('ERROR | Unknown parent product for variation: ' . $variation_post_id ); 1788 // let op: correcte DELETE syntaxis + prepared helper: 1789 $wpdb->delete($wpdb->postmeta, ['meta_id' => (int)$variation['meta_id']], ['%d']); 1790 continue; 1791 } 1792 1793 $stock = (int) max(0, (int)$product_variation['stock_total']); 1794 1795 // Dit wijzigt alléén voorraad; geen attributen of andere meta. 1796 wc_update_product_stock($variation_post_id, $stock, 'set'); 1797 wc_update_product_stock_status($variation_post_id, $stock > 0 ? 'instock' : 'outofstock'); 1798 1799 $logging->log_file_write( 1800 sprintf('StoreContrl | Update stock of variation: %d / %s to: %d', 1801 $variation_post_id, 1802 $product_variation['sku_id'], 1803 $stock 1804 ) 1805 ); 1806 1807 // Optioneel: backorders en sale-datums alleen via meta bij 0 voorraad 1808 if ($stock === 0) { 1811 1809 $_backorders = get_post_meta($variation_post_id, '_backorders', true); 1812 if ($_backorders != 'notify' && $_backorders != 'yes' ) { 1813 $Variation->set_date_on_sale_from(); 1814 $Variation->set_date_on_sale_to(); 1815 $Variation->set_backorders('no'); 1816 } 1817 } 1818 1819 $Variation->save(); 1820 1821 $this->functions->custom_update_post_meta($variation_post_id, 'latest_update', date('Y-m-d H:i')); 1822 } 1823 else{ 1824 $logging->log_file_write('StoreContrl | Unable to find variation: ' . $product_variation['sku_id']. ' to update a new stock total: ' .$product_variation['stock_total']); 1810 if ($_backorders !== 'notify' && $_backorders !== 'yes') { 1811 delete_post_meta($variation_post_id, '_sale_price_dates_from'); 1812 delete_post_meta($variation_post_id, '_sale_price_dates_to'); 1813 update_post_meta($variation_post_id, '_backorders', 'no'); 1814 } 1815 } 1816 1817 $this->functions->custom_update_post_meta($variation_post_id, 'latest_update', current_time('Y-m-d H:i')); 1818 } else { 1819 $logging->log_file_write('StoreContrl | Unable to find variation: ' . $product_variation['sku_id'] . ' to update a new stock total: ' . $product_variation['stock_total']); 1825 1820 } 1826 1821 } -
storecontrl-wp-connection/trunk/includes/cronjob/class-storecontrl-cronjob-functions.php
r3363222 r3370412 899 899 $changes = $web_api->curl_request("/Data/GetChanges", "GET", $args); 900 900 901 echo '<pre>';902 print_r($changes);903 echo '</pre>';904 905 901 if( isset($changes) && !empty($changes) ) { 906 902 … … 1539 1535 } 1540 1536 1541 // Reset sale products because they can be planned 1542 // Only ones after midnight 1543 if( date('H') == '01' || date('H') == '12' ){ 1544 $this->logging->log_file_write( 'Cronjob | Update sale products' ); 1537 // Draai alleen om 01:00 en 12:00 én als er geen lock staat 1538 $hour = (int) current_time('H'); 1539 if (in_array($hour, [1, 12], true) && ! get_transient('update_sale_products_lock')) { 1540 1541 // TTL tot nét voorbij het volgende uur (voorkomt dubbele runs in hetzelfde uur) 1542 $minutes = (int) current_time('i'); 1543 $ttl = ((60 - $minutes) + 5) * MINUTE_IN_SECONDS; 1544 set_transient('update_sale_products_lock', 1, $ttl); 1545 1546 $this->logging->log_file_write('Cronjob | Update sale products'); 1545 1547 $this->update_sale_products(); 1546 1548 } -
storecontrl-wp-connection/trunk/readme.txt
r3363222 r3370412 5 5 Requires at least: 6.6.0 6 6 Tested up to: 6.8.2 7 Stable tag: 4. 1.97 Stable tag: 4.2.0 8 8 Requires PHP: 8.0 9 9 License: GPLv2 or later … … 93 93 == Changelog == 94 94 95 = 4.2.0 = 96 * Nieuwe add_action na het verwerken van de afbeelingen: storecontrl_after_gallery_save 97 * Aangepaste stock update actie 98 95 99 = 4.1.9 = 96 100 * Wijziging in de verwerking van de afbeeldingen -
storecontrl-wp-connection/trunk/storecontrl-wp-connection.php
r3363222 r3370412 4 4 Plugin URI: http://www.arture.nl/storecontrl 5 5 Description: The Wordpress plugin for connecting Woocommerce with StoreContrl Cloud. With the synchronizing cronjobs your products will be automatically processed, images added, and the categories set. Every 5 minutes all stock changes are processed. We provide a up-to-date plugin, easy setup and always the best support. 6 Version: 4. 1.96 Version: 4.2.0 7 7 Requires Plugins: woocommerce 8 8 Author: Arture
Note: See TracChangeset
for help on using the changeset viewer.