Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Premmerce

    (@premmerce)

    Hi!

    Do you have some knowledge about web development, hooks and child themes?

    Thread Starter rookiefornow

    (@rookiefornow)

    Hi

    Thank you for getting back to me.

    I’ve managed to work out how to do this.. but I have another quick question. Can the ‘add to wishlist’ button be added to the Essential Grid? If so, is there a shortcode I can use? I would like to display my products on the Essential Grid instead of the normal shopfront.

    Thank you so much.

    Plugin Author Premmerce

    (@premmerce)

    Add to theme this code:

    add_shortcode('wishlist_button', function(){
       global $product;
       global $wishlistPage;
       $productId = $product->get_ID();
       $addUrl = premmerce_wishlist()->getAddPopupUrl($productId);
    
       if($wishlistPage){
           return '';
       }
    
       ob_start();
    
       ?>
    
       <div data-ajax-inject="wishlist-link--<?= $productId; ?>" >
    
           <div class="wishlist-btn-wrap" >
    
               <?php if(premmerce_wishlist()->checkInWishlist($productId)): ?>
                   <a class="button alt" rel="nofollow"
                      href="<?php echo premmerce_wishlist()->getWishlistUrl(); ?>">
                       <?php _e('View Wishlists','premmerce-wishlist'); ?>
                   </a>
               <?php else: ?>
                   <button class="button alt" data-modal-wishlist="<?= $addUrl; ?>">
                       <?php _e('View Wishlists','premmerce-wishlist'); ?>
                   </button>
               <?php endif; ?>
    
           </div>
       </div>
    
       <?php
    
       return ob_get_clean();
    
    });

    After this you will be able to use shortcode [wishlist_button]. Its will be work only with product.

    Thread Starter rookiefornow

    (@rookiefornow)

    Hi

    I tried the exact code but I’m getting the below error. Any ideas please? I tried it in my functions.php file in my child theme, and also in the Frontend.php file for the plugin. Thanks again

    Fatal error: Uncaught Error: Call to a member function get_ID() on null in /home2/myname/mydomain.com/wp-content/themes/x-child/functions.php:84 Stack trace: #0 /home2/myname/mydomain.com/wp-includes/shortcodes.php(319): {closure}(”, ”, ‘wishlist_button’) #1 [internal function]: do_shortcode_tag(Array) #2 /home2/myname/mydomain.com/wp-includes/shortcodes.php(197): preg_replace_callback(‘/\\[(\\[?)(wishli…’, ‘do_shortcode_ta…’, ‘[wishlist_butto…’) #3 /home2/myname/mydomain.com/wp-content/plugins/essential-grid/includes/item-skin.class.php(4744): do_shortcode(‘[wishlist_butto…’) #4 /home2/myname/mydomain.com/wp-content/plugins/essential-grid/includes/item-skin.class.php(2115): Essential_Grid_Item_Skin->insert_layer(Array, false, true, ‘1’, 1) #5 /home2/myname/mydomain.com/wp-content/plugins/essential-grid/includes/item-skin.class.php(2010): Essential_Grid_Item_Skin->insert_masonry_layer(false, ”, false, ‘1’, 1) #6 /home2/myname/mydomain.com/wp-content/plugins/essential-grid/publ in /home2/myname/mydomain.com/wp-content/themes/x-child/functions.php on line 84

    Plugin Author Premmerce

    (@premmerce)

    Please, try to trigger [wishlist_button] at the product, like this:

    add_action('woocommerce_after_shop_loop_item', function (){
     echo do_shortcode('[wishlist_button]');
    });
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Product Description’ is closed to new replies.