Changeset 3251737
- Timestamp:
- 03/06/2025 01:26:05 PM (13 months ago)
- Location:
- discontinued-product-stock-status-woocommerce
- Files:
-
- 139 added
- 6 edited
-
tags/1.5.4 (added)
-
tags/1.5.4/assets (added)
-
tags/1.5.4/assets/css (added)
-
tags/1.5.4/assets/css/discontinued_products.css (added)
-
tags/1.5.4/assets/css/sweetalert2.min.css (added)
-
tags/1.5.4/assets/images (added)
-
tags/1.5.4/assets/images/bfcm-sale-notice-img.png (added)
-
tags/1.5.4/assets/images/moneyback-badge.png (added)
-
tags/1.5.4/assets/images/saffiretech-quick-links-logo.png (added)
-
tags/1.5.4/assets/images/saffiretech_logo.png (added)
-
tags/1.5.4/assets/images/tooltip.png (added)
-
tags/1.5.4/assets/js (added)
-
tags/1.5.4/assets/js/discontinued.js (added)
-
tags/1.5.4/assets/js/dpssw-function.js (added)
-
tags/1.5.4/assets/js/sweetalert2.all.min.js (added)
-
tags/1.5.4/discontinued-products-stock-status.php (added)
-
tags/1.5.4/includes (added)
-
tags/1.5.4/includes/dpssw-functions.php (added)
-
tags/1.5.4/includes/dpssw-product-data-tabs.php (added)
-
tags/1.5.4/languages (added)
-
tags/1.5.4/languages/discontinued-products-stock-status.POT (added)
-
tags/1.5.4/library (added)
-
tags/1.5.4/library/action-scheduler (added)
-
tags/1.5.4/library/action-scheduler/README.md (added)
-
tags/1.5.4/library/action-scheduler/action-scheduler.php (added)
-
tags/1.5.4/library/action-scheduler/changelog.txt (added)
-
tags/1.5.4/library/action-scheduler/classes (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_ActionClaim.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_ActionFactory.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_AdminView.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_AsyncRequest_QueueRunner.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_Compatibility.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_DataController.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_DateTime.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_Exception.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_FatalErrorMonitor.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_InvalidActionException.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_ListTable.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_LogEntry.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_NullLogEntry.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_OptionLock.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_QueueCleaner.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_QueueRunner.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_Versions.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_WPCommentCleaner.php (added)
-
tags/1.5.4/library/action-scheduler/classes/ActionScheduler_wcSystemStatus.php (added)
-
tags/1.5.4/library/action-scheduler/classes/WP_CLI (added)
-
tags/1.5.4/library/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php (added)
-
tags/1.5.4/library/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php (added)
-
tags/1.5.4/library/action-scheduler/classes/WP_CLI/Migration_Command.php (added)
-
tags/1.5.4/library/action-scheduler/classes/WP_CLI/ProgressBar.php (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts/ActionScheduler.php (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts/ActionScheduler_Abstract_ListTable.php (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts/ActionScheduler_Abstract_Schedule.php (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts/ActionScheduler_Abstract_Schema.php (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts/ActionScheduler_Lock.php (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts/ActionScheduler_Logger.php (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts/ActionScheduler_Store.php (added)
-
tags/1.5.4/library/action-scheduler/classes/abstracts/ActionScheduler_TimezoneHelper.php (added)
-
tags/1.5.4/library/action-scheduler/classes/actions (added)
-
tags/1.5.4/library/action-scheduler/classes/actions/ActionScheduler_Action.php (added)
-
tags/1.5.4/library/action-scheduler/classes/actions/ActionScheduler_CanceledAction.php (added)
-
tags/1.5.4/library/action-scheduler/classes/actions/ActionScheduler_FinishedAction.php (added)
-
tags/1.5.4/library/action-scheduler/classes/actions/ActionScheduler_NullAction.php (added)
-
tags/1.5.4/library/action-scheduler/classes/data-stores (added)
-
tags/1.5.4/library/action-scheduler/classes/data-stores/ActionScheduler_DBLogger.php (added)
-
tags/1.5.4/library/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php (added)
-
tags/1.5.4/library/action-scheduler/classes/data-stores/ActionScheduler_HybridStore.php (added)
-
tags/1.5.4/library/action-scheduler/classes/data-stores/ActionScheduler_wpCommentLogger.php (added)
-
tags/1.5.4/library/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php (added)
-
tags/1.5.4/library/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostStatusRegistrar.php (added)
-
tags/1.5.4/library/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php (added)
-
tags/1.5.4/library/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php (added)
-
tags/1.5.4/library/action-scheduler/classes/migration (added)
-
tags/1.5.4/library/action-scheduler/classes/migration/ActionMigrator.php (added)
-
tags/1.5.4/library/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php (added)
-
tags/1.5.4/library/action-scheduler/classes/migration/BatchFetcher.php (added)
-
tags/1.5.4/library/action-scheduler/classes/migration/Config.php (added)
-
tags/1.5.4/library/action-scheduler/classes/migration/Controller.php (added)
-
tags/1.5.4/library/action-scheduler/classes/migration/DryRun_ActionMigrator.php (added)
-
tags/1.5.4/library/action-scheduler/classes/migration/DryRun_LogMigrator.php (added)
-
tags/1.5.4/library/action-scheduler/classes/migration/LogMigrator.php (added)
-
tags/1.5.4/library/action-scheduler/classes/migration/Runner.php (added)
-
tags/1.5.4/library/action-scheduler/classes/migration/Scheduler.php (added)
-
tags/1.5.4/library/action-scheduler/classes/schedules (added)
-
tags/1.5.4/library/action-scheduler/classes/schedules/ActionScheduler_CanceledSchedule.php (added)
-
tags/1.5.4/library/action-scheduler/classes/schedules/ActionScheduler_CronSchedule.php (added)
-
tags/1.5.4/library/action-scheduler/classes/schedules/ActionScheduler_IntervalSchedule.php (added)
-
tags/1.5.4/library/action-scheduler/classes/schedules/ActionScheduler_NullSchedule.php (added)
-
tags/1.5.4/library/action-scheduler/classes/schedules/ActionScheduler_Schedule.php (added)
-
tags/1.5.4/library/action-scheduler/classes/schedules/ActionScheduler_SimpleSchedule.php (added)
-
tags/1.5.4/library/action-scheduler/classes/schema (added)
-
tags/1.5.4/library/action-scheduler/classes/schema/ActionScheduler_LoggerSchema.php (added)
-
tags/1.5.4/library/action-scheduler/classes/schema/ActionScheduler_StoreSchema.php (added)
-
tags/1.5.4/library/action-scheduler/deprecated (added)
-
tags/1.5.4/library/action-scheduler/deprecated/ActionScheduler_Abstract_QueueRunner_Deprecated.php (added)
-
tags/1.5.4/library/action-scheduler/deprecated/ActionScheduler_AdminView_Deprecated.php (added)
-
tags/1.5.4/library/action-scheduler/deprecated/ActionScheduler_Schedule_Deprecated.php (added)
-
tags/1.5.4/library/action-scheduler/deprecated/ActionScheduler_Store_Deprecated.php (added)
-
tags/1.5.4/library/action-scheduler/deprecated/functions.php (added)
-
tags/1.5.4/library/action-scheduler/functions.php (added)
-
tags/1.5.4/library/action-scheduler/lib (added)
-
tags/1.5.4/library/action-scheduler/lib/WP_Async_Request.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression_AbstractField.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression_DayOfMonthField.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression_DayOfWeekField.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression_FieldFactory.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression_FieldInterface(1).php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression_FieldInterface.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression_HoursField.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression_MinutesField.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression_MonthField.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/CronExpression_YearField.php (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/LICENSE (added)
-
tags/1.5.4/library/action-scheduler/lib/cron-expression/README.md (added)
-
tags/1.5.4/library/action-scheduler/license.txt (added)
-
tags/1.5.4/library/action-scheduler/node_modules (added)
-
tags/1.5.4/library/action-scheduler/node_modules/.package-lock.json (added)
-
tags/1.5.4/library/action-scheduler/readme.txt (added)
-
tags/1.5.4/library/action-scheduler/vendor (added)
-
tags/1.5.4/library/action-scheduler/vendor/autoload.php (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer/ClassLoader.php (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer/InstalledVersions.php (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer/LICENSE (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer/autoload_classmap.php (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer/autoload_namespaces.php (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer/autoload_psr4.php (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer/autoload_real.php (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer/autoload_static.php (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer/installed.json (added)
-
tags/1.5.4/library/action-scheduler/vendor/composer/installed.php (added)
-
tags/1.5.4/readme.txt (added)
-
tags/1.5.4/wpml-config.xml (added)
-
trunk/assets/js/discontinued.js (modified) (9 diffs)
-
trunk/discontinued-products-stock-status.php (modified) (2 diffs)
-
trunk/includes/dpssw-functions.php (modified) (6 diffs)
-
trunk/includes/dpssw-product-data-tabs.php (modified) (9 diffs)
-
trunk/languages/discontinued-products-stock-status.pot (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
discontinued-product-stock-status-woocommerce/trunk/assets/js/discontinued.js
r3083405 r3251737 33 33 }).trigger('change'); 34 34 35 35 36 36 jQuery('select#product-type').change(function () { 37 37 productType = jQuery(this).val(); 38 38 39 if ('variable' == productType || 'grouped' == productType ) {39 if ('variable' == productType || 'grouped' == productType || 'simple' === productType) { 40 40 jQuery('input#_discontinued_product').parent().show(); 41 41 } else { … … 44 44 }); 45 45 jQuery('select#product-type').trigger('change'); 46 47 // To hide and show message box on variable product level. i.e when checked on 'Discontinued Product'.48 jQuery('input#_discontinued_product').on('change', function () {49 50 var is_discontinued_product = jQuery('input#_discontinued_product:checked').size();51 variElements = jQuery(this).parent().siblings();52 productType = jQuery('select#product-type').val();53 54 55 if (is_discontinued_product) {56 // if (is_discontinued_product) {57 58 jQuery(this).parent().siblings('p.form-field.show_specific_messsage_field').show();59 jQuery(this).parent().siblings('div#wp-custom_editor_box-wrap').show();60 61 let prodType = variElements.find('select#show_specific_messsage').val();62 63 if ('product_specific_message' == prodType) {64 65 jQuery(this).parent().siblings('div#wp-custom_editor_box-wrap').show();66 } else {67 jQuery(this).parent().siblings('div#wp-custom_editor_box-wrap').hide();68 }69 } else if ('simple' != productType) {70 71 jQuery(this).parent().siblings('p.form-field.show_specific_messsage_field').hide();72 jQuery(this).parent().siblings('div#wp-custom_editor_box-wrap').hide();73 74 }75 76 }).trigger('change');77 46 78 47 // To hide and show message box on variable product level. i.e when checked on 'Discontinued Product'. … … 175 144 stockStatus = jQuery('#_stock_status').val(); 176 145 var savedStkStatus = stockStatus; 177 146 178 147 // Swapping between different Product types. 179 148 if ( 'simple' === productType ) { … … 193 162 } 194 163 164 165 // To hide and show message box on variable product level. i.e when checked on 'Discontinued Product'. 166 jQuery('input#_discontinued_product').on('change', function () { 167 var is_discontinued_product = jQuery('input#_discontinued_product:checked').size(); 168 variElements = jQuery(this).parent().siblings(); 169 productType = jQuery('select#product-type').val(); 170 171 if (is_discontinued_product) { 172 // if (is_discontinued_product) { 173 jQuery(this).parent().siblings('p.form-field.show_specific_messsage_field').show(); 174 jQuery(this).parent().siblings('p.form-field.related_product_header_field').show(); 175 jQuery(this).parent().siblings('p.form-field.related_to_disc_prod_field').show(); 176 jQuery(this).parent().siblings('div#wp-custom_editor_box-wrap').show(); 177 178 let prodType = variElements.find('select#show_specific_messsage').val(); 179 180 if ('product_specific_message' == prodType) { 181 182 jQuery(this).parent().siblings('div#wp-custom_editor_box-wrap').show(); 183 } else { 184 jQuery(this).parent().siblings('div#wp-custom_editor_box-wrap').hide(); 185 } 186 } else { 187 console.log('else'); 188 jQuery(this).parent().siblings('p.form-field.show_specific_messsage_field').hide(); 189 jQuery(this).parent().siblings('div#wp-custom_editor_box-wrap').hide(); 190 jQuery(this).parent().siblings('p.form-field.related_product_header_field').hide(); 191 jQuery(this).parent().siblings('p.form-field.related_to_disc_prod_field').hide(); 192 193 } 194 195 }).trigger('change'); 196 197 195 198 jQuery('#_stock_status').on('change', function () { 196 199 197 200 var stockStatus = ''; 198 201 stockStatus = jQuery('#_stock_status').val(); 202 console.log('stock status fired'); 199 203 200 204 if ( 'discontinued' === stockStatus ) { 201 jQuery("#_discontinued_product").prop("checked", true) ;205 jQuery("#_discontinued_product").prop("checked", true).trigger('change'); 202 206 } else { 203 207 jQuery("#_discontinued_product").prop("checked", false); … … 205 209 }); 206 210 211 207 212 jQuery('#_discontinued_product').on('change', function () { 208 213 … … 212 217 jQuery("#_stock_status").val("discontinued"); 213 218 } else { 214 jQuery("#_stock_status").val(savedStkStatus); 219 if ( stockStatus === savedStkStatus && 'discontinued' === savedStkStatus ) { 220 jQuery("#_stock_status").val('outofstock'); 221 } else { 222 jQuery("#_stock_status").val(savedStkStatus); 223 } 215 224 } 216 225 }); 217 226 218 // Hide all the Settings on Discontinued Checkbox from Discontinued Products for Variable Products.219 if ( ( 'discontinued' === stockStatus ) && ( jQuery('#_discontinued_product').is(":checked") ) ) {220 jQuery('#show_specific_messsage').parent().show();221 jQuery('#related_product_header').parent().show();222 jQuery('#related_to_disc_prod').parent().show();223 } else {224 if ( 'simple' === productType ) {225 jQuery('#show_specific_messsage').parent().show();226 } else {227 jQuery('#show_specific_messsage').parent().hide();228 }229 jQuery('#related_product_header').parent().hide();230 jQuery('#related_to_disc_prod').parent().hide();231 }232 233 227 // Validation based on changing the Product type. 234 228 jQuery('#product-type').on('change', function () { … … 252 246 } 253 247 } 254 255 if ( ( 'discontinued' === stockStatus ) && ( jQuery('#_discontinued_product').is(":checked") ) ) { 248 }); 249 250 251 // Validation for Hiding and Showing settings for Simple Product. 252 jQuery('#_stock_status').on('change', function () { 253 254 var stockStatus = ''; 255 stockStatus = jQuery('#_stock_status').val(); 256 257 if ( 'discontinued' === stockStatus ) { 256 258 jQuery('#show_specific_messsage').parent().show(); 257 259 jQuery('#related_product_header').parent().show(); 258 260 jQuery('#related_to_disc_prod').parent().show(); 259 260 } else { 261 if ( 'simple' === productType ) { 262 jQuery('#show_specific_messsage').parent().show(); 261 262 let prodType = jQuery('select#show_specific_messsage').val(); 263 264 if ('product_specific_message' == prodType) { 265 jQuery('div#wp-custom_editor_box-wrap').show(); 263 266 } else { 264 jQuery('#show_specific_messsage').parent().hide(); 265 } 267 jQuery('div#wp-custom_editor_box-wrap').hide(); 268 } 269 270 } else { 271 jQuery('#show_specific_messsage').parent().hide(); 266 272 jQuery('#related_product_header').parent().hide(); 267 273 jQuery('#related_to_disc_prod').parent().hide(); 268 } 269 }); 270 271 // Validation for Hiding and Showing settings for Simple Product. 272 jQuery('#_stock_status').on('change', function () { 273 274 var stockStatus = ''; 275 stockStatus = jQuery('#_stock_status').val(); 276 277 if ( 'discontinued' === stockStatus ) { 278 jQuery('#related_product_header').parent().show(); 279 jQuery('#related_to_disc_prod').parent().show(); 280 } else { 281 jQuery('#related_product_header').parent().hide(); 282 jQuery('#related_to_disc_prod').parent().hide(); 274 jQuery('div#wp-custom_editor_box-wrap').hide(); 283 275 } 284 276 … … 287 279 // Validation for Hiding and Showing settings for non-Simple Product (like Variable and Grouped). 288 280 jQuery('#_discontinued_product').on('change', function () { 289 290 281 if ( jQuery('#_discontinued_product').is(":checked") ) { 291 282 jQuery('#show_specific_messsage').parent().show(); … … 300 291 }); 301 292 302 // Hide Header Text Field and Dropdown field of Similar Products on Add Similar Products Checbox.303 if ( 'discontinued' === stockStatus && jQuery('#_discontinued_product').is(":checked") ) {304 jQuery('#related_product_header').parent().show();305 jQuery('#related_to_disc_prod').parent().show();306 } else {307 jQuery('#related_product_header').parent().hide();308 jQuery('#related_to_disc_prod').parent().hide();309 }310 293 311 294 jQuery("#related_product_header").attr('disabled', 'disabled'); -
discontinued-product-stock-status-woocommerce/trunk/discontinued-products-stock-status.php
r3234439 r3251737 7 7 * Text Domain: discontinued-products-stock-status 8 8 * Domain Path: /languages 9 * Stable Tag : 1.5. 39 * Stable Tag : 1.5.4 10 10 * Requires at least: 5.0 11 11 * Tested up to: 6.7.1 … … 14 14 * License: GPLv3 15 15 * License URI: https://www.gnu.org/licenses/gpl-3.0.html 16 * Version: 1.5. 316 * Version: 1.5.4 17 17 */ 18 18 -
discontinued-product-stock-status-woocommerce/trunk/includes/dpssw-functions.php
r3234439 r3251737 59 59 function dpssw_apply_greyscale_effect_on_discontinued_products() { 60 60 global $product; 61 // check for empty product. 61 62 if ( ! empty( $product ) ) { 62 63 $product_id = $product->get_id(); // gets product id. … … 179 180 */ 180 181 function dpssw_hide_price_discontinued_variations( $condition, $product, $variation ) { 181 if ( $variation->get_stock_status() === 'discontinued' ) { 182 return false; 182 // check for empty variation product. 183 if ( ! empty( $variation ) ) { 184 if ( $variation->get_stock_status() === 'discontinued' ) { 185 return false; 186 } else { 187 return true; 188 } 183 189 } else { 184 190 return true; … … 210 216 foreach ( $product->get_visible_children() as $variation_id ) { 211 217 get_stock_discontinued_status( $variation_id ); // update the stock status. 212 $variation = wc_get_product( $variation_id ); // Get product. 213 $stock_status = $variation->get_stock_status(); // Get stock status. 218 $variation = wc_get_product( $variation_id ); // Get product. 219 if ( ! empty( $variation ) ) { 220 $stock_status = $variation->get_stock_status(); // Get stock status. 221 } 214 222 } 215 223 } … … 288 296 289 297 global $post; 298 // check for empty post. 290 299 if ( empty( $post ) ) { 291 300 return ''; … … 336 345 */ 337 346 function dpssw_hide_price_discontinued_grouped( $price, $product, $child_prices ) { 347 // check for empty product. 338 348 if ( empty( $product ) ) { 339 349 return $price; … … 358 368 359 369 global $product; 370 // check for empty product. 360 371 if ( ! empty( $product ) ) { 361 372 $product_id = $product->get_id(); // gets product id. -
discontinued-product-stock-status-woocommerce/trunk/includes/dpssw-product-data-tabs.php
r3234439 r3251737 848 848 function dpssw_save_discontinued_product_option_fields( $post_id ) { 849 849 $product = wc_get_product( $post_id ); // product object. 850 // check for empty product. 850 851 if ( empty( $product ) ) { 851 852 return ''; … … 952 953 function dpssw_add_wc_discontinued_variation_data( $data, $product, $variation ) { 953 954 954 if ( $variation->get_stock_status() === 'discontinued' ) { 955 956 $variation_id = $variation->get_id(); 957 $message = ''; 958 $message_type = get_post_meta( $variation_id, '_discontinued_messsage_type', true ); 959 $custom_message_disable = get_option( 'discontinued_enable_custom_message' ); 960 $message = ! empty( get_option( 'discontinued_global_message' ) ) ? get_option( 'discontinued_global_message' ) : __( 'This product has been discontinued.', 'discontinued-products-stock-status' ); 961 962 if ( 'yes' === $custom_message_disable ) { 963 964 if ( 'variations_specific_message' === $message_type ) { 965 $variation_message = get_post_meta( $variation_id, '_variable_discontinued_textarea', true ); 966 $message = ! empty( $variation_message ) ? $variation_message : $message; 967 // If variation_message is empty then by default global message is rendered. 968 if ( ! empty( $variation_message ) ) { 969 $message_html = '<div class=discontinued_status_message>' . esc_attr( $message ) . '</div>'; 970 } else { 955 if ( ! empty( $variation ) ) { 956 if ( $variation->get_stock_status() === 'discontinued' ) { 957 958 $variation_id = $variation->get_id(); 959 $message = ''; 960 $message_type = get_post_meta( $variation_id, '_discontinued_messsage_type', true ); 961 $custom_message_disable = get_option( 'discontinued_enable_custom_message' ); 962 $message = ! empty( get_option( 'discontinued_global_message' ) ) ? get_option( 'discontinued_global_message' ) : __( 'This product has been discontinued.', 'discontinued-products-stock-status' ); 963 964 if ( 'yes' === $custom_message_disable ) { 965 966 if ( 'variations_specific_message' === $message_type ) { 967 $variation_message = get_post_meta( $variation_id, '_variable_discontinued_textarea', true ); 968 $message = ! empty( $variation_message ) ? $variation_message : $message; 969 // If variation_message is empty then by default global message is rendered. 970 if ( ! empty( $variation_message ) ) { 971 $message_html = '<div class=discontinued_status_message>' . esc_attr( $message ) . '</div>'; 972 } else { 973 $message_html = '<div class=discontinued_status_message>' . esc_attr( $message ) . '</div>'; 974 } 975 } elseif ( 'global_text_message' === $message_type ) { // This will work when message_type is 'global_text_message'. 971 976 $message_html = '<div class=discontinued_status_message>' . esc_attr( $message ) . '</div>'; 972 977 } 973 } else if ( 'global_text_message' === $message_type ) { // This will work when message_type is 'global_text_message'.978 } else { // This will work when custom_message_disable is 'yes'. Global message will be overridden. 974 979 $message_html = '<div class=discontinued_status_message>' . esc_attr( $message ) . '</div>'; 975 980 } 976 } else { // This will work when custom_message_disable is 'yes'. Global message will be overridden. 977 $message_html = '<div class=discontinued_status_message>' . esc_attr( $message ) . '</div>'; 981 982 $data['availability_html'] = apply_filters( 'dpssw_customize_variation_product_message', $message_html ); // modify the variation product message. 983 978 984 } 979 980 $data['availability_html'] = apply_filters( 'dpssw_customize_variation_product_message', $message_html ); // modify the variation product message.981 982 985 } 983 986 return $data; … … 994 997 $product_id = $post->ID; 995 998 $product = wc_get_product( $product_id ); 999 // check for empty product. 996 1000 if ( empty( $product ) ) { 997 1001 return ''; … … 1038 1042 function dpssw_save_custom_stock_status( $product_id ) { 1039 1043 $product = wc_get_product( $product_id ); // product object. 1040 if ( empty( $product ) ) {1041 return '';1042 }1043 1044 1044 1045 // save stock status for simple product. … … 1046 1047 1047 1048 update_post_meta( $product_id, '_stock_status', wc_clean( sanitize_text_field( wp_unslash( $_POST['_stock_status'] ) ) ) ); 1048 $product->set_stock_status( wc_clean( sanitize_text_field( wp_unslash( $_POST['_stock_status'] ) ) ) ); 1049 $product->save(); 1049 // check for empty product. 1050 if ( ! empty( $product ) ) { 1051 $product->set_stock_status( wc_clean( sanitize_text_field( wp_unslash( $_POST['_stock_status'] ) ) ) ); 1052 $product->save(); 1053 } 1050 1054 } 1051 1055 } … … 1062 1066 */ 1063 1067 function dpssw_woocommerce_admin_stock_html( $stock_html, $product ) { 1068 // check for empty product. 1064 1069 if ( empty( $product ) ) { 1065 1070 return $stock_html; … … 1404 1409 // Get the product variation object 1405 1410 $variation = wc_get_product( $variation_id ); 1406 1407 // saves variation product option data. 1408 if ( isset( $variable_discontinued_option ) ) { 1409 update_post_meta( $variation_id, '_stock_discontinued_product', 'yes' ); 1410 $stock_quantity = $variation->get_stock_quantity(); 1411 1412 if ( $stock_quantity == 0 ) { 1413 update_post_meta( $variation_id, '_stock_status', 'discontinued' ); 1411 // check if product variation is empty. 1412 if ( ! empty( $variation ) ) { 1413 // saves variation product option data. 1414 if ( isset( $variable_discontinued_option ) ) { 1415 update_post_meta( $variation_id, '_stock_discontinued_product', 'yes' ); 1416 $stock_quantity = $variation->get_stock_quantity(); 1417 1418 if ( $stock_quantity == 0 ) { 1419 update_post_meta( $variation_id, '_stock_status', 'discontinued' ); 1420 } 1421 } else { 1422 update_post_meta( $variation_id, '_stock_discontinued_product', '' ); 1423 1424 if ( $variation && $variation->is_type( 'variation' ) ) { 1425 // Get stock status. 1426 $stock_status = $variation->get_stock_status(); // 'instock', 'outofstock', 'onbackorder' 1427 update_post_meta( $variation_id, '_stock_status', $stock_status ); 1428 } else { 1429 update_post_meta( $variation_id, '_stock_status', '' ); 1430 1431 } 1414 1432 } 1415 } else { 1416 update_post_meta( $variation_id, '_stock_discontinued_product', '' ); 1417 1418 if ( $variation && $variation->is_type( 'variation' ) ) { 1419 // Get stock status. 1420 $stock_status = $variation->get_stock_status(); // 'instock', 'outofstock', 'onbackorder' 1421 update_post_meta( $variation_id, '_stock_status', $stock_status ); 1422 } else { 1423 update_post_meta( $variation_id, '_stock_status', '' ); 1424 1425 } 1426 } 1433 } 1434 1427 1435 } 1428 1436 … … 1435 1443 */ 1436 1444 function dpssw_custom_bulk_edit_save_action( $product ) { 1445 // check for empty product. 1437 1446 if ( empty( $product ) ) { 1438 1447 return ''; … … 1462 1471 // Get an instance of the WC_Product object. 1463 1472 $product = wc_get_product( $product_id ); 1464 1465 // Get product stock quantity and stock status. 1466 $stock_quantity = $product->get_stock_quantity(); 1467 $stock_status = $product->get_stock_status(); 1468 1469 // Set product stock quantity (zero) and stock status (out of stock). 1470 $product->set_stock_quantity( 0 ); 1471 $product->set_stock_status( 'outofstock' ); 1472 1473 // Save the data and refresh caches. 1474 $product->save(); 1473 // check for empty product. 1474 if ( ! empty( $product ) ) { 1475 // Get product stock quantity and stock status. 1476 // $stock_quantity = $product->get_stock_quantity(); 1477 // $stock_status = $product->get_stock_status(); 1478 1479 // Set product stock quantity (zero) and stock status (out of stock). 1480 $product->set_stock_quantity( 0 ); 1481 $product->set_stock_status( 'outofstock' ); 1482 1483 // Save the data and refresh caches. 1484 $product->save(); 1485 } 1475 1486 } 1476 1487 } -
discontinued-product-stock-status-woocommerce/trunk/languages/discontinued-products-stock-status.pot
r3234439 r3251737 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Discontinued Product Stock Status for WooCommerce 1.5. 3\n"5 "Project-Id-Version: Discontinued Product Stock Status for WooCommerce 1.5.4\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/discontinued-product-stock-status-woocommerce\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2025-0 2-04T06:30:43+00:00\n"12 "POT-Creation-Date: 2025-03-06T13:01:07+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.11.0\n" … … 135 135 msgstr "" 136 136 137 #: includes/dpssw-functions.php:3 05138 #: includes/dpssw-functions.php:3 11139 #: includes/dpssw-functions.php:4 00140 #: includes/dpssw-functions.php:4 09141 #: includes/dpssw-product-data-tabs.php:96 0137 #: includes/dpssw-functions.php:314 138 #: includes/dpssw-functions.php:320 139 #: includes/dpssw-functions.php:411 140 #: includes/dpssw-functions.php:420 141 #: includes/dpssw-product-data-tabs.php:962 142 142 msgid "This product has been discontinued." 143 143 msgstr "" 144 144 145 #: includes/dpssw-functions.php:5 31145 #: includes/dpssw-functions.php:542 146 146 msgid "Permission Denied." 147 147 msgstr "" 148 148 149 #: includes/dpssw-functions.php:5 76149 #: includes/dpssw-functions.php:587 150 150 msgid "Awesome, you've been using" 151 151 msgstr "" 152 152 153 #: includes/dpssw-functions.php:5 76153 #: includes/dpssw-functions.php:587 154 154 msgid "for more than 1 week" 155 155 msgstr "" 156 156 157 #: includes/dpssw-functions.php:5 77157 #: includes/dpssw-functions.php:588 158 158 msgid "If you like our plugin would you like to rate our plugin at WordPress.org ?" 159 159 msgstr "" 160 160 161 #: includes/dpssw-functions.php:5 79161 #: includes/dpssw-functions.php:590 162 162 msgid "Yes, I'd like to rate it!" 163 163 msgstr "" 164 164 165 #: includes/dpssw-functions.php:5 82165 #: includes/dpssw-functions.php:593 166 166 msgid "I already did!" 167 167 msgstr "" … … 490 490 491 491 #: includes/dpssw-product-data-tabs.php:799 492 #: includes/dpssw-product-data-tabs.php:89 4492 #: includes/dpssw-product-data-tabs.php:895 493 493 msgid "Global Message" 494 494 msgstr "" … … 522 522 msgstr "" 523 523 524 #: includes/dpssw-product-data-tabs.php:8 89524 #: includes/dpssw-product-data-tabs.php:890 525 525 msgid "Discontinued Message Type" 526 526 msgstr "" 527 527 528 #: includes/dpssw-product-data-tabs.php:89 5528 #: includes/dpssw-product-data-tabs.php:896 529 529 msgid "Variation Specific Message" 530 530 msgstr "" 531 531 532 #: includes/dpssw-product-data-tabs.php:89 8532 #: includes/dpssw-product-data-tabs.php:899 533 533 msgid "Choose type of message to be displayed for Discontinued product" 534 534 msgstr "" 535 535 536 #: includes/dpssw-product-data-tabs.php:90 7536 #: includes/dpssw-product-data-tabs.php:908 537 537 msgid "Discontinued description" 538 538 msgstr "" 539 539 540 #: includes/dpssw-product-data-tabs.php:10 26541 #: includes/dpssw-product-data-tabs.php:107 3542 #: includes/dpssw-product-data-tabs.php:108 0543 #: includes/dpssw-product-data-tabs.php:10 89540 #: includes/dpssw-product-data-tabs.php:1030 541 #: includes/dpssw-product-data-tabs.php:1078 542 #: includes/dpssw-product-data-tabs.php:1085 543 #: includes/dpssw-product-data-tabs.php:1094 544 544 msgid "Discontinued" 545 545 msgstr "" 546 546 547 #: includes/dpssw-product-data-tabs.php:134 2547 #: includes/dpssw-product-data-tabs.php:1347 548 548 msgid "Mark this entire product as 'Discontinued' once it's stock becomes zero" 549 549 msgstr "" 550 550 551 #: includes/dpssw-product-data-tabs.php:134 4552 #: includes/dpssw-product-data-tabs.php:138 3551 #: includes/dpssw-product-data-tabs.php:1349 552 #: includes/dpssw-product-data-tabs.php:1388 553 553 msgid "Check this box if you want to set the stock status of this product to 'Discontinued' after stock quantity becomes zero." 554 554 msgstr "" 555 555 556 #: includes/dpssw-product-data-tabs.php:138 1556 #: includes/dpssw-product-data-tabs.php:1386 557 557 msgid "Mark this variation as 'Discontinued' once it's stock becomes zero." 558 558 msgstr "" -
discontinued-product-stock-status-woocommerce/trunk/readme.txt
r3234439 r3251737 5 5 Tested up to: 6.7.1 6 6 Requires PHP: 7.2 7 Stable tag: 1.5. 37 Stable tag: 1.5.4 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 75 75 76 76 == Changelog == 77 = 1.5.4 2025-03-06 = 78 79 * New - Added checkbox to discontinue simple products in the Discontinued Products tab. 80 77 81 = 1.5.3 2025-02-04 = 78 82
Note: See TracChangeset
for help on using the changeset viewer.