WordPress.org

Support

Support » Plugins and Hacks » eShop » [Resolved] [Plugin: eShop] Feature Request (Requires Addition of ONE LINE)

[Resolved] [Plugin: eShop] Feature Request (Requires Addition of ONE LINE)

  • justbishop

    @justbishop

    Hey, I was just wondering if this plugin could possibly be updated to hide the add to cart form on single.php (or page.php, wherever people are adding items) when it’s a post scheduled to publish in the future? I’ve already hacked the current version to do it, but am trying to avoid having to go in and re-edit every time the plugin is upgraded. It only requires the addition of one line to eshop-add-cart.php as follows:

    FIND
    `if($stkav==’1′){
    $currsymbol=$eshopoptions[‘currency_symbol’];`

    ADD BEFORE
    if ($post->post_status == 'future') $stkav = '0';

    That makes it so that the add to cart form can be filled out on the backend, schedule the post/page for publishing, and the form itself won’t be rendered until the post/page actually goes live. The author can then just let WP take over and be assured that their item won’t be offered for sale until they’ve specified. Very useful for people (like myself) who might want to use a custom template with a “post_status=future” query to allow the public to preview items that will be up for sale sometime in the future 😉

    Special thanks to KostasDi and sha1sum from #wordpress IRC for helping me out with this!

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

    @elfin

    Although that solution is right for you, it isn’t the best solution for all. Because you wouldn’t be able to see the addtocart form until after the page had been published – and if you used the shortcode to have the form within the content… you also wouldn’t see it.

    So currently I’ll say no to that – but I can see that some people may want it. So I’ve added in a filter for the next release, and you’ll be able to filter like this:

    add_filter('eshop_show_addtocart','myeshop_show_addtocart',10,3);
    function myeshop_show_addtocart($stkav,$postid,$post){
    	if($post->post_status == 'future')
    		$stkav=0;
    	return $stkav;
    }

    the $postid may not be needed – but I haven’t fully tested this for all cases, so leaving it in just in case.

    justbishop

    @justbishop

    Thanks 🙂

    As long as the ability to prevent the form from being seen until the post is published, I’m happy! Does your solution mean that there will be a checkbox or something to specify whether to show the form or not until published on the add/edit page?

    Plugin Author elfin

    @elfin

    no, it just does as you suggested, except via a filter/function.

    justbishop

    @justbishop

    Ah, just easier for those who’d like it to NOT work that way to disable, then? Sorry, I gotz the filter dumz, lol

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] [Plugin: eShop] Feature Request (Requires Addition of ONE LINE)’ is closed to new replies.
Skip to toolbar