Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('woocommerce_after_shop_loop_item', 'myprefix_bm_product_to_favorites', 8 );
- add_action('woocommerce_after_add_to_cart_form', 'myprefix_bm_product_to_favorites', 9 );
- function myprefix_bm_product_to_favorites() {
- if( !function_exists( 'buddyboss_bm' ) )
- return;
- $obj = buddyboss_bm();
- remove_action('woocommerce_after_shop_loop_item', array( $obj, 'bm_product_to_favorites' ), 9 );
- remove_action('woocommerce_after_add_to_cart_form', array( $obj, 'bm_product_to_favorites' ) );
- $product_id = get_the_ID();
- $vendor_id = WCV_Vendors::get_vendor_from_product( $product_id );
- $current_user = bp_loggedin_user_id();
- if($current_user && $current_user != $vendor_id) {
- $favorites = get_user_meta($current_user, "favorite_products", true);
- $class = (is_array($favorites) && in_array($product_id, $favorites)) ? ' favorited' : '';
- $tooltip = __('Add to Favorites', 'buddyboss-marketplace');
- if($class) {
- $tooltip = __('Remove from Favorites', 'buddyboss-marketplace');
- }
- echo '<a href="#" class="boss-tooltip bm-product-to-favorites ' . $class . '" data-tooltip="'.$tooltip.'" data-id="' . $product_id . '"><i class="fa fa-thumbs-up"></i></a>';
- }
- }
Add Comment
Please, Sign In to add comment