This file contains hidden or 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 | |
/** | |
* @return Generator<WC_Product> | |
*/ | |
function fetch_all_products(): Generator { | |
$page = 1; | |
while ( true ) { | |
$products = wc_get_products( [ |
This file contains hidden or 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 | |
/** | |
* For subscription products, overrides the default product price string with | |
* something custom. | |
*/ | |
add_filter( | |
'woocommerce_subscriptions_product_price_string', | |
function ( string $product_price_string, WC_Product $product ): string { | |
// Update the criteria as needed to target the correct product(s). |
This file contains hidden or 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 | |
/** | |
* Avoid conflicts between WP Console and WooCommerce. | |
* | |
* In the context of WP CLI and specifically the `wp shell` command, we may wish to unhook WooCommerce's CLI integration | |
* for the Blueprint package to prevent a conflict between its dependencies and those of WP Console. | |
* | |
* Relevant versions when this snippet was written: | |
* | |
* - WooCommerce 10.1.0 |
This file contains hidden or 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: Simple Subscriptions UI | |
* Description: Simplifies the WooCommerce Subscriptions admin UI. Prototype/experimental. | |
* Version: 1.0.0 | |
* Text Domain: simple-subscriptions-ui | |
* License: GPL-2.0+ | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt | |
* | |
* @package simple-subscriptions-ui |
This file contains hidden or 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 | |
/** | |
* This script can be used to quickly add a stack of renewals | |
* to an existing subscription. Can be useful when testing | |
* scalability concerns for WooCommerce Subscriptions. | |
*/ | |
function generate_renewal_order_for_subscription( $subscription_id ) { | |
$subscription = new WC_Subscription( $subscription_id ); |
This file contains hidden or 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 | |
/** | |
* Temporary fix for https://github.com/woocommerce/woocommerce/issues/53057. | |
*/ | |
add_action( | |
'after_plugin_row', | |
function () { | |
global $wp_list_table; |
This file contains hidden or 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
#!/bin/bash | |
# Attempts to list PRs merged since a given tag was created. | |
# | |
# Run from within the repo you are interested in (of course fetch/pull | |
# down all the latest changes from remote). | |
# | |
# Usage: prs-merged-since <tag_name> | |
# Example: prs-merged-since v1.0.0 |
This file contains hidden or 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 | |
/** | |
* When the product permalink structure is `product/%product_cat%`, WooCommerce (9.3.x or earlier) | |
* accepts any value as the `%product_cat%`, which is not always desirable. | |
* | |
* This snippet attempts to detect this situation, and will redirect to the canonical URL as needed. | |
* You can add it as a mu-plugin. For example: | |
* | |
* wp-content/mu-plugins/canonical-product-redirect.php |
This file contains hidden or 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 | |
/** | |
* Removes the 'site visibility badge' from the WordPress admin bar. | |
* | |
* Intended for use with WooCommerce 9.3.1, can be used via a code | |
* snippet manager or else you may wish to add as a mu-plugin, ie: | |
* | |
* wp-content/mu-plugin/disable-site-visibility-badge.php | |
*/ |
This file contains hidden or 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 | |
add_filter( | |
'rest_post_dispatch', | |
function ( $response, $server, $request ) { | |
if ( | |
$request->get_route() === '/wc/v3/orders' | |
&& $request->get_param( '_fields' ) === [ 'id' ] | |
&& $request->get_param( '_vendor' ) === 'flag' | |
) { |
NewerOlder