This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Simple approach showing a structured approach to associating arbitrary, ephemeral | |
* (non-persisted) data with individual product objects and other entities. | |
* | |
* Benefits include avoidance of collisions between two plugins using the same key, | |
* the range of checks that can be applied to stored values, etc. | |
* | |
* @link https://github.com/woocommerce/woocommerce/issues/45286 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Assigns currently unassigned product attribute terms to products, to try and | |
* replicate the problem in the linked issue. Also generates new unassigned terms | |
* on each request, to further exacerbate things. | |
* | |
* We deliberately do not use the WooCommerce API, because in this case we are | |
* try to circumvent WC's cache invalidation logic. | |
* | |
* @see https://github.com/woocommerce/woocommerce/issues/17355 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin name: Detect Legacy REST API Usage (WooCommerce) | |
* Description: Attempts to detect and log usage of WooCommerce's legacy REST API. | |
* Version: 2023-11-24.1 | |
*/ | |
function detect_and_log_wc_legacy_api_requests() { | |
global $wp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The top-seller query (used for the WooCommerce Status dashboard widget) | |
* runs on every dashboard request. | |
* | |
* It can effectively be nullified using this snippet, if the performance | |
* impact is too great. | |
* | |
* (Tested with WC 8.0.2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Modify /wp-json/wc/store/v1/products/<ID> so that it returns more complete data about each variation. | |
* | |
* Not extensively tested, just captures an idea about how we might do this. | |
*/ | |
add_filter( 'rest_request_after_callbacks', function ( $response, $handler, $request ) { | |
// If this is not a Store API product request, do not interfere. | |
if ( ! str_starts_with( $request->get_route(), '/wc/store/v1/products/' ) || $request->get_method() !== 'GET' ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/plugins/woocommerce/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php b/plugins/woocommerce/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php | |
index 4b140a814f..5719a8a12b 100644 | |
--- a/plugins/woocommerce/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php | |
+++ b/plugins/woocommerce/includes/shipping/flat-rate/class-wc-shipping-flat-rate.php | |
@@ -177,8 +177,16 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method { | |
// Also handles BW compatibility when slugs were used instead of ids. | |
$shipping_class_term = get_term_by( 'slug', $shipping_class, 'product_shipping_class' ); | |
$class_cost_string = $shipping_class_term && $shipping_class_term->term_id ? $this->get_option( 'class_cost_' . $shipping_class_term->term_id, $this->get_option( 'class_cost_' . $shipping_class, '' ) ) : $this->get_option( 'no_class_cost', '' ); | |
- | |
- if ( '' === $class_cost_string ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Cleans up any non-pending WooCommerce Update Callback scheduled actions | |
-- and the corresponding log table entries. | |
-- | |
-- Note that in many cases you may need to adjust the table prefix from | |
-- 'wp_' to whatever is in effect within your site. | |
DELETE actions, | |
action_logs | |
FROM wp_actionscheduler_actions AS actions | |
JOIN wp_actionscheduler_logs AS action_logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE actions, | |
action_logs | |
FROM wp_actionscheduler_actions AS actions | |
JOIN wp_actionscheduler_logs AS action_logs | |
ON actions.action_id = action_logs.action_id | |
WHERE actions.hook = 'woocommerce_run_update_callback' | |
AND actions.status <> 'pending' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Every 2 mins (`-n 120` where 120 is num seconds), display a new joke. | |
# | |
# - On MacOS you may need to `brew install watch` first of all. | |
# - Fun to place this in a small Tmux pane | |
watch -n 120 "curl -s -H \"Accept: text/plain\" https://icanhazdadjoke.com/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generates a set of scheduled actions for testing purposes. | |
* | |
* Additionally, it provides test callbacks (which do very little except burn time). | |
* How much fun is that? | |
* | |
* An easy way to add this command is to place the file in the wp-content/mu-plugins | |
* directory, or else incldue it from a file in that directory. | |
* |
NewerOlder