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 | |
| /** | |
| * See https://woocommerce.github.io/code-reference/classes/WC-Order.html#property_data for all data items in the WC_Order | |
| */ | |
| /** | |
| * This line is not needed within the filter as $order is passed as a parameter | |
| */ | |
| $order_data = $order->get_data(); |
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
| /** | |
| * Add Stripe metadata along with WooCommerce purchase | |
| * | |
| * @param $metadata | |
| * @param $order | |
| * @param $source | |
| * @return mixed | |
| */ | |
| function wbdc_filter_wc_stripe_payment_metadata( $metadata, $order, $source ) { |
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
| /* Redirect user after check out */ | |
| function zpd_wc_global_redirect_after_payment() { | |
| global $wp; | |
| $redirect_url = 'https://yourdomain.com/this-page/'; | |
| if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) { | |
| wp_redirect( $redirect_url ); | |
| exit; | |
| } |
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
| SELECT 'autoloaded data in KiB' as name, ROUND(SUM(LENGTH(option_value))/ 1024) as value FROM wp_options WHERE autoload='yes' | |
| UNION | |
| SELECT 'autoloaded data count', count(*) FROM wp_options WHERE autoload='yes' | |
| UNION | |
| (SELECT option_name, length(option_value) FROM wp_options WHERE autoload='yes' ORDER BY length(option_value) DESC LIMIT 10); |
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
| /** | |
| * Set a minimum amount for checkout | |
| */ | |
| function zpd_wc_minimum_order_amount(): void { | |
| /** | |
| * $minimum is the minimum value you want to set the checkout total order amount. | |
| */ | |
| $minimum = 50; | |
| /** |
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
| /** | |
| * Change the default shop page 'catalogue' order of how products are displayed | |
| * | |
| * You can use the following parameters: | |
| * 'menu_order' – by the custom order first, then by product name (Default) | |
| * 'popularity' – by the number of sales | |
| * 'rating' – by the average rating | |
| * 'date' – recently added products will be displayed first | |
| * 'price' – cheapest products will be displayed first | |
| * 'price-desc' – the most expensive first |
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
| /** | |
| * Add extra emails to the WC email sent when an order has been completed. | |
| * | |
| * Make sure you separate multiple emails with a comma. | |
| * | |
| * @param $recipient | |
| * @param $object | |
| * @return string | |
| */ | |
| function zpd_wc_extra_email_recipient( $recipient, $object ): string { |
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
| /** | |
| * Removes commenting from WordPress | |
| * | |
| * Redirects edit comment URL to admin URL | |
| * Removes comment meta box | |
| * Removes comments and trackback support for all post types | |
| */ | |
| function zpd_remove_commenting () { | |
| // Redirect any user trying to access comments page | |
| global $pagenow; |
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
| /** | |
| * Finds product varant option dropdown with " - sold out" and adds a "sold-out" class to the option. | |
| * You can add the following CSS to grey-out the sold out option | |
| * option.sold-out{ color:lightgray;} | |
| */ | |
| jQuery(window).load(function(){ | |
| jQuery('body.single-product .product.type-product table.variations td.value select option').each(function( index ){ | |
| var optionText = jQuery(this).text(); | |
| if( optionText.indexOf(" - sold out") >= 0 ){ | |
| jQuery(this).addClass( 'sold-out' ); |
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
| /** | |
| * Generate an order ID based on the billing customers initials and a random number between 10000 and 99999 | |
| * | |
| * @author Wil Brown zeropointdevelopment.com | |
| * @param $order_id | |
| * | |
| * @return string | |
| * @throws Exception | |
| */ | |
| function zpd_change_woocommerce_order_number( $order_id ) { |