• Resolved yoneo12

    (@yoneo12)


    Hi,

    I want to create a button which is linked to the wishlist. But the URL is something like https://[shopurl].com/wunschliste/B87A11/ (individualized).

    I haven′t found a shortcode for the wishlist page url. If the solution is already somewhere in the docs/forum written, please let me know.

    Thanks in advance

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author templateinvaders

    (@templateinvaders)

    Hi @yoneo12

    You can use the next snippet to get wishlist URL with sharekey:
    https://gist.github.com/doozy/f8fd3a1ef4ba514f398e71f317fb6c88

    Thread Starter yoneo12

    (@yoneo12)

    Perfect, thank you for the solution!

    Thread Starter yoneo12

    (@yoneo12)

    Sorry, I am a beginner in PHP. I have tried many things, but I cannot find a solution to get the URL.

    Here my code. It is located at mytheme/framework/includes/pluggable.

                $class = array("menu-item with-icon");
                ob_start();
                ?>
                <li class="<?php echo esc_attr( implode( ' ', $class ) ); ?>">
    				<?php 
    
    				// Get wishlist for current user.
    				$wl = tinv_wishlist_get();
    
    				// Get share key for wishlist if exists.
    
    				$share_key = ( $wl && isset( $wl['share_key'] ) ) ? $wl['share_key'] : '';
    
    				// Get wishlist url with share key if exists.
    				$wlisturl = tinv_url_wishlist_by_key( $share_key );
    
    				?>
                    <a  href="<?php $wlisturl ?>"><?php echo familab_icons('search');?></a>
                    <?php //self::header_search_form($search_form_close_button,$show_title,$show_category);?>
                </li>

    With this implementation, the code redirects only to the actual page.

    Can you give me a hint?

    Best regards

    Plugin Author templateinvaders

    (@templateinvaders)

    Hi @yoneo12

    You got wishlist URL as a variable but forgot to print it out at markup here:
    <a href="<?php $wlisturl ?>">

    try to use <a href="<?php echo $wlisturl; ?>">

    Thread Starter yoneo12

    (@yoneo12)

    Thank you so much for your help.

    That works. But I have one problem with this solution:

    If a (non registered) user has nothing in his wishlist yet and he clicks on the wishlist link, it goes to a 404 page.
    That is a strange behavior, because the linked page exists (there is the shortcode for TI Wishlist view). If one item is saved to wishlist, then it works perfectly.
    I want to redirect the user, if nothing is in his wishlist yet, to a page where he can see a message about this (or in best case opens a small popup with the information).

    I hope, you understand my problem. Have you an idea, how to fix the 404 page?

    Best regards

    • This reply was modified 4 years, 9 months ago by yoneo12.
    Plugin Author templateinvaders

    (@templateinvaders)

    Hi @yoneo12

    Sorry for the delayed reply.
    We are just back to this project.

    If you are using the mentioned snippet to get wishlist URL for guests who don’t have a wishlist yet it will return the general wishlist URL. It can’t throw a 404 error if you specify the wishlist page in our plugin settings.

    Thread Starter yoneo12

    (@yoneo12)

    Yes, you are right, my page was suspicious broken. With another wishlist page (where the shortcode is added), it works fine. Thank you for the help!

    Sorry!

    The above snippet allows you to print the wishlist URL in code, but how do I link to the wishlist from the nav? I can only paste a page link in there, no PHP. Is there a different shortcode for “current wishlist”?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to create a Link to the wishlist page?’ is closed to new replies.