• Hello,

    I’m a theme developer and need the URL of the page that the user has set for the wishlist page to link to it via an icon in the header.
    I found the list of shortcode at https://yithemes.com/docs-plugins/yith-woocommerce-wishlist/02-shortcode.html but the shortcode wishlist_url is not replaced by anything when I use it in my php file with echo do_shortcode('[wishlist_url]');. I just see [wishlist_url] but not the URL.
    How can I get the link?

    And another question: I want to add an little icon to every productimage on the product stream (product overview) page that adds the product to the wishlist when the icon is clicked. How can that be done without requiring the theme owner to set the “add to wishlist” position to “shortcode” in the plugins settings?
    I would probably need to check if the product is already added (exists shortcode) and if not show the icon and apply the function to add it to the linked icon. But which shortcode does the “add function”?

    Thanks in advance,
    Felix

    https://www.ads-software.com/plugins/yith-woocommerce-wishlist/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi Felix,

    Sorry, no [wishlist_url] shortcode is available; as stated in the doc, “wishlist_url” is only an attribute of the shortcode [yith_wcwl_add_to_wishlist], inserted for future purpose.

    Anyway, there is a simple way to obtain wishlist page url:

    if( function_exists( 'YITH_WCWL' ) ){
        $wishlist_url = YITH_WCWL()->get_wishlist_url();
    }

    The “if” just check wishlist plugin is enabled.

    To show an “Add to wishlist” button in your product loop, you can try to add this in your functions.php

    function yith_loop_add_to_shortcode_button(){
        echo do_shortcode( '[yith_wcwl_add_to_wishlist]' );
    }
    add_action( 'woocommerce_after_shop_loop_item', 'yith_loop_add_to_shortcode_button' );

    Obviously, you can change woocommerce hook, to change button position; then, you can customize the button with style,css of your theme

    Hope this help with your work
    Have a nice day ??

    Thread Starter colibriinteractive

    (@colibriinteractive)

    Thanks for your feedback!
    How can I check if a product is already added to the wishlist?
    I found the ‘exists’ parameter but not sure how to use it.
    When I do an echo do_shortcode('[yith_wcwl_add_to_wishlist exists]'); I get the same as without it ??

    What I’m looking for is to show icon A to add it to the wishlist and button B if it’s already added.

    Thanks in advance!
    Felix

    Plugin Author YITHEMES

    (@yithemes)

    Hi again Felix!

    I think you should just use the shortcode with no params, and overwrite the “add-to-wishlist” templates.

    Locate the files

    wp-content/plugins/yith-woocommerce-wishlist/templates/add-to-wishlist.php
    and
    wp-content/plugins/yith-woocommerce-wishlist/templates/add-to-wishlist-button.php

    and paste them in your theme root.

    Now you can change them as you wish ?? I suggest to check lines 22/39 on add-to-wishlist.php and 14 on add-to-wishlist-button.php

    Let me know if this help you with your purpose

    Have a nice day ??

    Thread Starter colibriinteractive

    (@colibriinteractive)

    Thanks for you reply!

    I’m using this code currently directly in the content-product.php which works fine but I give you version a try to. Looks a bit cleaner!

    $default_wishlists = is_user_logged_in() ? YITH_WCWL()->get_wishlists( array( 'is_default' => true ) ) : false;
    
    if( ! empty( $default_wishlists ) ){
        $default_wishlist = $default_wishlists[0]['ID'];
    }
    else{
        $default_wishlist = false;
    }
    if(YITH_WCWL()->is_product_in_wishlist( $product->id, $default_wishlist )) {
        echo 'A';
    } else {
        echo 'B';
    }

    I get back to you if I need a hand again.

    Thanks!
    Felix

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Shortcode with Wishlist page URL?’ is closed to new replies.