Thread Starter
Abhishek
(@abhishekyesankar)
Never Mind I have find the solution on this thread.
In case anyone needs it :
add_shortcode( 'cus_wishlist_shortcode', 'woo_wishlist_shortcode_func' );
function woo_wishlist_shortcode_func() {
if ( ! is_object( $product) ) {
$product = wc_get_product( get_the_ID() );
$wt_wishlist = new WT_Wishlist_Singlepage();
$wt_wishlist->render_webtoffee_wishlist_button();
}
}
-
This reply was modified 3 years, 4 months ago by
Abhishek.
-
This reply was modified 3 years, 4 months ago by
Abhishek.
I’m using another block to work inside products loop, which also can be encapsulated into shortcode function. Just added some check to avoid crashing if plugin is inactive:
if (in_array('wt-woocommerce-wishlist/wishlist-webtoffee.php', apply_filters('active_plugins', get_option('active_plugins')))){
$wt_wishlist = new WT_Wishlist_Looppage();
$wt_wishlist->render_webtoffee_wishlist_button();
}
So, shortcode for “Add to wishlist” button, which you can place anywhere in a loop of product blocks will be like this:
add_shortcode( 'cus_wishlist_loop_shortcode', 'woo_wishlist_loop_shortcode_func' );
function woo_wishlist_loop_shortcode_func() {
if (in_array('wt-woocommerce-wishlist/wishlist-webtoffee.php', apply_filters('active_plugins', get_option('active_plugins')))){
$wt_wishlist = new WT_Wishlist_Looppage();
$wt_wishlist->render_webtoffee_wishlist_button();
}
}