Okay
  Public Ticket #1757635
Shop page
Closed

Comments

  • ji2chauhan started the conversation

    I am trying to override the file woocommerce.php (themes/foodfarm/inc/functions/woocommerce.php) in child theme. But changes are not reflecting. Basically I want to change the product image url to directly add item in cart (on image click) rather than directing user to product detail page.

    For that I need to change foodfarm_template_loop_product_thumbnail function.

    But changes are not reflecting in child theme. 

    Kindly revert ASAP.


  •  608
    WordPress replied

    Hi,

    You should follow the instruction below:

    1. remove that function in functions.php file in child theme

    remove_action( 'woocommerce_before_shop_loop_item_title', 'foodfarm_template_loop_product_thumbnail', 10 );

    2. Add new overriden function into this action

    add_action( 'overriden function', 'woocommerce_before_shop_loop_item_title', 20 );

    Thanks

    Kind Regard.


  • ji2chauhan replied

    I tried what you suggested.
    It does not work.

    URL: https://farmlandng.com/shop/

    Here is the code..

    Kindly revert.

    <?php

    // push your child theme functions here

    remove_action( 'woocommerce_before_shop_loop_item_title', 'foodfarm_template_loop_product_thumbnail', 10 );

    add_action( 'changethumburl', 'woocommerce_before_shop_loop_item_title', 20 );

    function changethumburl(){
      global $product;
        ?>
        <a href="#">
            <?php echo  woocommerce_get_product_thumbnail(); ?>
        </a>
        <?php

    }

  •  608
    WordPress replied

    Hi, 

    Sorry for not giving you details of the instruction.

    You should write a function like this in functions.php in child theme. Try this.

    add_action( 'init', 'remove_my_action' );
    function remove_my_action() {
         //remove action here     //add action here
    } //Function needs overriden here

    Kind regard.