• So by default this plugin outputs the review badge (the stars) after the product titles. If you want to remove these and output them somewhere else it is currently impossible (at least I couldn’t figure out a way without hacking the plugin).

    In the view folder, the file cls_stamped_io_public.php states you can show the review badge via “a Public Static function call directly from any class Like Woo_stamped_public::Woo_stamped_review_badge()”. This is correct and I was able to output the review badge where I needed.

    BUT you cannot remove the original output of Woo_stamped_review_badge (or any of the other display functions) because all the display functions seem to be wrapped in a class that does not allow for hooks to be used.

    From my very limited understanding of PHP this is bad practice and goes against OOP standards.

    The problem lies with the way the cls_stamped_io_public.php file ends with

    new Woo_stamped_public();

    It needs to be tied to a function (not sure if that is the correct term) and so I changed the above to:

    global $Woo_stamped_public_class;
    $Woo_stamped_public_class = new Woo_stamped_public();

    By adding this hack I am now able to call $Woo_stamped_public_class in my plugin or functions.php file. PLEASE ADD THIS TO YOUR PLUGIN or similar. Or please tell me how I can use remove_action to disable the default review badge.

    To recap:
    This is the code I was trying to use and it DOES NOT work

    add_action('plugins_loaded', 'steamist_move_archive_reviews' , 0);
    function steamist_move_archive_reviews() {
    	 remove_action('woocommerce_after_shop_loop_item_title', array('Woo_stamped_public' , 'Woo_stamped_review_badge'), 6);
    	add_action('woocommerce_shop_loop_item_title', array('Woo_stamped_public' , 'Woo_stamped_review_badge'), 6);
    }

    So I fixed the file above with my global and now this DOES WORK

    add_action('plugins_loaded', 'steamist_move_archive_reviews' , 0);
    function steamist_move_archive_reviews() {
    	global $Woo_stamped_public_class;
    	 remove_action('woocommerce_after_shop_loop_item_title', array($Woo_stamped_public_class , 'Woo_stamped_review_badge'), 6);
    	add_action('woocommerce_shop_loop_item_title', array('Woo_stamped_public' , 'Woo_stamped_review_badge'), 6);
    }
  • The topic ‘Fix for not being able to Hook the Review Badge Output’ is closed to new replies.