• Resolved Jonas Grumby

    (@ss_minnow)


    I’m trying to use do_shortcode to tell the Post Layout plugin to insert Add To Cart icons on archive pages. The shortcode that I am trying to use is [eshop_addtocart]. I have tried:

    <? php do_shortcode ([eshop_addtocart]); ?>

    and

    <? php do_shortcode ('[eshop_addtocart]'); ?>

    but those don’t seem to work. Can someone help steer me in the right direction? I have searched the forum and the docs but still don’t understand how to make this work.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php echo do_shortcode('[eshop_addtocart]'); ?>

    Thread Starter Jonas Grumby

    (@ss_minnow)

    Thanks kz.

    That makes all of the text that is supposed to be around the button display (product name, options, shipping rate, etc.) but not the actual Add To Cart button.

    This also produces the same results:

    <?php echo (do_shortcode("[eshop_addtocart]")); ?>

    An example page is here if you want to see it:

    https://alliesnaturalvending.com/products/soda/

    This site is currently under development.

    Thanks

    Thread Starter Jonas Grumby

    (@ss_minnow)

    It’s actually a little more complicated than that because first you have to edit the eshop plugin so that the Add To Cart button will display on Archive pages by changing this line in eshop-get-custom.php

    if((!strpos($pee, '[eshop_addtocart]')) && ((is_single() || is_page())|| 'yes'

    to read:

    if((!strpos($pee, '[eshop_addtocart]')) && ((is_single() || is_page() || is_archive())|| 'yes'

    That will make the button appear at the bottom of every post on archive pages UNLESS your archive pages are set to show an abbreviated version of the post, AND the button is after the cutoff point in the content.

    That’s what got me to thinking that I could use the Post Layout plugin to insert the code at the top of each archive post (between the post title and the post body). This only works though if you have already done the above hack to the plugin. Then if you don’t have enough text to move the button past the cutoff line, it appears twice (top and bottom of content).

    In my case the buttons DO show up when I use the Default theme, but only the text that is supposed to go with the button shows with Atahualpa, which is the theme they want to use. So, now I have to figure out why this theme is causing this problem, and I have to add more text to some of the products that have short descriptions or no description…

    Thanks

    Thread Starter Jonas Grumby

    (@ss_minnow)

    Ok all fixed. The secret w/ Atahualpa is to make a copy of index.php and name it archive.php, search.php (or whatever page you are trying to modify) and then replace the part where The Loop is with loop code from a theme that basically does what you are trying to do. Then upload your file.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Syntax for using do_shortcode function’ is closed to new replies.