Home > Software design >  run a specific filter or functions on woocommerce checkout page
run a specific filter or functions on woocommerce checkout page

Time:10-03

actully i want to resize the cart item thumbnail on checkout page of woocommerce currently i am using this filter in my child theme

add_filter( 'woocommerce_get_image_size_thumbnail', function( $size ) {
    return array(
    'width' => 427,
    'height' => 427,
    'crop' => 0,
    );
    } );

but when i add this in my child functions .. it also resize the thubnail of main home page. i want this function to run only on woocommerce checkout page. please help me to fix that. i have tried is_page function also but running into error.

CodePudding user response:

You can use Woocommerce Conditional tag of Checkout Page.

if ( is_checkout() ) {
  // Your Code Here
} 

Source: https://docs.woocommerce.com/document/conditional-tags/

CodePudding user response:

You can use the WooCommerce Visual Hook to run the code only on the checkout

add_action('woocommerce_before_checkout_form','function_name');
function function_name(){
   //your code here
}

source:https://www.businessbloomer.com/woocommerce-visual-hook-guide-checkout-page

  • Related