0

I'm trying to make a post, which will list product meta(every order will have only one product) and on that post I want to make visible product variations. So the link will be generated and sent to users mail (I have an idea of sending that email). So whenever the order is created, I need a post for every one order. I only need a direction, in which way should I look. Thanks in advance.

6
  • WooCoomerce can already send a e-mail with the order, you don't have to create this, look in the configuration
    – mmm
    Aug 3, 2015 at 9:32
  • Yes I do understand that, but I actually need an option where everyone can visit a page which lists all the order info (not the price and quantity, let's say there is a name, a contact info and some other strings which are order variations)
    – hrvojeA
    Aug 3, 2015 at 9:47
  • I think this also exist in WooCommerce, there is a customer backoffice with order pages to see in progress orders and closed orders. look in the configuration of WooCommerce on the "account" tab
    – mmm
    Aug 3, 2015 at 10:38
  • Yes You're correct, that is one of the options but only for users. I want something like mywebsite.com/something/something_else_123123 and to be visible for everyone (guests and registered users). There would be product name, few strings from the order and that is all. I am thinking of making a post (wp_insert_post) from 'thankyou' page where I will pull info from the woocommerce table, actually from that order and insert it to the post content.
    – hrvojeA
    Aug 3, 2015 at 10:46
  • ok I understand now. for doing this, I would try something else : for example making the orders public instead of private and filter the ordre display if the connected (or unconnected) user is the owner of the order - I will try to make a answer with some code as soon as I have more time
    – mmm
    Aug 3, 2015 at 13:45

1 Answer 1

1

in comments I propose to make the order as public but I found a easier way to display a order : with a shortcode

i try this in a plugin :

add_shortcode("view_order", function ($atts, $content = "", $tag) {

    if (!isset($_GET["order_id"])) {
        return "no id";
    }


    $order = get_post($_GET["order_id"]);

    if (    !isset($order)
        ||  ("shop_order" !== $order->post_type)
    ) {
        return "no shop_order";
    }


    // result of the shortcode

    ob_start();

    echo "<pre>";
    print_r($order);
    echo "</pre>";

    return ob_get_clean();
});

.
then in a page ("preview order" in my exemple) put the shortcode [view_order] and you can see the details of the order on the URL :
http://server/preview-order/?order_id=23

1
  • Nice one, @mmm. I was struggling to make orders publicly queryable but this will meet my requirement instead. Mar 16, 2017 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.