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
/* | |
* Add "Products" to Stripe metadata | |
*/ | |
function filter_wc_stripe_payment_metadata( $metadata, $order, $source ) { | |
$count = 1; | |
foreach( $order->get_items() as $item_id => $line_item ){ | |
$item_data = $line_item->get_data(); | |
$product = $line_item->get_product(); | |
$product_name = $product->get_name(); |
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
function add_additonal_wc_mime_types($mime_types) { | |
$mime_types['webp'] = 'image/webp'; // Add support for webp images in the WooCommerce Product importer. | |
return $mime_types; | |
} | |
add_filter('woocommerce_rest_allowed_image_mime_types', 'add_additonal_wc_mime_types', 1, 1); |
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
add_filter('woocommerce_add_to_cart_validation', 'check_num_of_subscriptions', 10, 2); | |
function check_num_of_subscriptions( $valid, $product_id ) | |
{ | |
$product_to_add = wc_get_product( $product_id ); | |
if ( $product_to_add instanceof WC_Product_Subscription || $product_to_add instanceof WC_Product_Variable_Subscription) { | |
// alternative use: $has_sub = wcs_user_has_subscription( '', '', 'active' ); | |
if ( has_active_subscription() ) { |
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
// show newest product reviews on top | |
function sd_newest_reviews_first( $args ) { | |
$args['reverse_top_level'] = true; | |
return $args; | |
} | |
add_filter( 'woocommerce_product_review_list_args', 'sd_newest_reviews_first' ); |
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
function remove_handheld_search( $links ) { | |
unset( $links['search'] ); | |
return $links; | |
} | |
add_filter( 'storefront_handheld_footer_bar_links', 'remove_handheld_search' ); |
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
function storefront_product_search() { | |
if ( storefront_is_woocommerce_activated() ) { | |
?> | |
<div class="site-search"> | |
<?php the_widget( 'WP_Widget_Search', 'title=' ); ?> | |
</div> | |
<?php | |
} | |
} |
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
function remove_wc_stripe_from_checkout_page( $available_gateways ) { | |
unset( $available_gateways['stripe'] ); | |
return $available_gateways; | |
} | |
add_filter( 'woocommerce_available_payment_gateways', 'remove_wc_stripe_from_checkout_page' ); |
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
// New order notification only for "Pending" Order status | |
add_action( 'woocommerce_checkout_order_processed', 'pending_new_order_notification', 20, 1 ); | |
function pending_new_order_notification( $order_id ) { | |
// Get an instance of the WC_Order object | |
$order = wc_get_order( $order_id ); | |
// Only for "pending" order status | |
if( ! $order->has_status( 'pending' ) ) return; | |
// Get an instance of the WC_Email_New_Order object |
NewerOlder