• Resolved jimmylet

    (@jimmylet)


    Hello,

    Thanks for this great tool!

    I want to use a shortcode to import where I want (below the cart button on my product page) the stories.

    Only, when I do it, there is a bug. When I click on the cross to close the stories, it does not work.

    [web_stories excerpt="false" image_alignment="left" author="false" date="false" archive_link="false" view="circles" circle_size="100" sharp_corners="false"]

    I specify that when I use the stories block directly from Guttenberg, it works.

    Worse, when I import the shortcode into the Guttenberg “shortcode” block, it works too.

    But when I use PHP to import the shortcode on my product page, it doesn’t work.

    I can see the URL changed (it goes from the archive URL to the URL of my product page) but the classes that are supposed to be removed to close the lightbox are not removed.

    Example of my PHP CODE :

    <?php
    function add_webstories_list_after_add_to_cart() {
    ?>
    <div class="text-white text-[1px]">test</div>
    <?php echo do_shortcode('[web_stories excerpt="false" image_alignment="left" author="false" date="false" archive_link="false" view="circles" circle_size="100" sharp_corners="false"]'); ?>
    <?php
    }

    // Ajouter la fonction au hook 'woocommerce_after_add_to_cart_button'
    add_action('woocommerce_after_add_to_cart_button', 'add_webstories_list_after_add_to_cart');

    Can you help ?

    Thanks from Belgium!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jimmylet

    (@jimmylet)

    I noticed that when I import shortcode directly into the php file view (e.g. single-product.php), then it works.

    The problem comes when I care about it thanks to a hook, as in my example

    Thread Starter jimmylet

    (@jimmylet)

    I’m progressing with my tests…

    The import works when using hooks like add_action, but on condition that the files are root files.

    For example: single-product.php

    But it won’t work if you call a hook of an element that is imported into single-product.php.

    Using the action “woocommerce_after_main_content” that is in single-product.php, it works.

    Using “woocommerce_after_cart_button” that is not present in single-product.php (but is imported through various hooks), it won’t work.

    What should I do to fix this problem?

    @jimmylet Could you please share an example URL where this issue is occurring?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can’t exit web stories when imported via shortcode’ is closed to new replies.