Add WooCommerce upsells below the add-to-cart button (copy)
// add upsells below add-to-cart button add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_upsell_display’, 40 );Continue reading
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
// add upsells below add-to-cart button add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_upsell_display’, 40 );Continue reading
function remove_plugin_filter() { remove_filter( ‘woocommerce_product_is_visible’, ‘MeprRulesCtrl::override_wc_is_visible’, 11, 2); remove_filter( ‘woocommerce_variation_is_visible’, ‘MeprRulesCtrl::override_wc_is_visible’, 11, 4); } add_action( ‘plugins_loaded’, ‘remove_plugin_filter’ );Continue reading
add_action( ‘woocommerce_single_product_summary’, ‘display_product_formated_dimensions_table’, 25 ); function display_product_formated_dimensions_table(){ global $product; if ( $product->has_dimensions() ) { echo ‘ ‘ . __( ‘Dimensions’, ‘woocommerce’ ) . ‘ ‘ . esc_html( wc_format_dimensions( $product->get_dimensions( false ) ) ) . ‘ ‘; } }Continue reading
/** * Sorting SDEK shipping methods by cost, from cheap to expensive * * @param array $rates Array of shipping methods * * @return array */ add_filter( ‘woocommerce_package_rates’, function( $rates ) { if( empty( $rates ) || ! is_array( $rates…Continue reading
// WC – limit one course at a time (id 45639 / Fundamentals Private Networks) add_filter( ‘woocommerce_add_to_cart_validation’, ‘wc_limit_one_45639_per_order’, 10, 2 ); function wc_limit_one_45639_per_order( $passed_validation, $product_id ) { if ( 45639 !== $product_id ) { return $passed_validation; } if ( WC()->cart->get_cart_contents_count()…Continue reading
// WC – limit one course at a time (id 50697 / Fundamentals Public Safety) add_filter( ‘woocommerce_add_to_cart_validation’, ‘wc_limit_one_50697_per_order’, 10, 2 ); function wc_limit_one_50697_per_order( $passed_validation, $product_id ) { if ( 50697 !== $product_id ) { return $passed_validation; } if ( WC()->cart->get_cart_contents_count()…Continue reading
// add order suffix add_filter(‘woe_get_order_value_order_number’, ‘suffix_order_id_for_product_50697’, 10, 2 ); function suffix_order_id_for_product_50697( $order_id, $order ) { // Check if the order contains the specified product $product_id_to_check = 50697; $order_contains_product = false; foreach ( $order->get_items() as $item_id => $item ) { if…Continue reading
// add order suffix add_filter(‘woe_get_order_value_order_number’, ‘suffix_order_id_for_product_45639’, 10, 2 ); function suffix_order_id_for_product_45639( $order_id, $order ) { // Check if the order contains the specified product $product_id_to_check = 45639; $order_contains_product = false; foreach ( $order->get_items() as $item_id => $item ) { if…Continue reading
// WC – avoid other items to be added to cart when a specific product category (free courses) is already in cart add_filter( ‘woocommerce_add_to_cart_validation’, ‘check_and_limit_cart_free_items’, 10, 3 ); function check_and_limit_cart_free_items ( $passed, $product_id, $quantity ){ // HERE set your product…Continue reading
// Automatically Delete Woocommerce Images After Deleting a Product add_action( ‘before_delete_post’, ‘delete_product_images’, 10, 1 ); function delete_product_images( $post_id ) { $product = wc_get_product( $post_id ); if ( !$product ) { return; } $featured_image_id = $product->get_image_id(); $image_galleries_id = $product->get_gallery_image_ids(); if( !empty(…Continue reading