[resolved] Feature Request (Requires Addition of ONE LINE) (5 posts)

  1. justbishop
    Posted 5 years ago #

    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:


    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!

  2. elfin

    Plugin Author

    Posted 5 years ago #

    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:

    function myeshop_show_addtocart($stkav,$postid,$post){
    	if($post->post_status == 'future')
    	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.

  3. justbishop
    Posted 5 years ago #

    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?

  4. elfin

    Plugin Author

    Posted 5 years ago #

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

  5. justbishop
    Posted 5 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic