Account page with transaction history

Hello,

I am looking to sell physical products through Marketpress and premium content subscriptions through Protected Content.

1) Is there a way to have the Protected Content subscription sold in the MarketPress as a 'product'? I am hoping someone can buy a physical product and a subscription in one place in one order.

2) Secondly, is there one page, like an account page, that would have in one place, transaction history of both subscriptions and physical products.

Thanks,
Stephen

  • Tyler Postle

    Hey Stephen,

    Hope you're doing well today!

    Thanks for your questions.

    1) Is there a way to have the Protected Content subscription sold in the MarketPress as a 'product'? I am hoping someone can buy a physical product and a subscription in one place in one order.

    Subscriptions can only be purchased through the Protected Content checkout at this time. Purchasing a membership requires specific parameters sent through as it needs to apply the subscription to the user and also setup that payment inside whichever payment gateway you're using.

    I'll move this into feature requests though as I think it would be a convenient feature to have :slight_smile:

    2) Secondly, is there one page, like an account page, that would have in one place, transaction history of both subscriptions and physical products.

    This would require some cusotmization as well, but Protected Content does have some handy shortcodes to make this a little bit easier :slight_smile:

    You could place this into the MarketPress "my order" page template:

    [ms-membership-account show_profile="no" show_activity="no" show_membership="no"]

    That will display only the membership invoices to the logged in user.

    You can find more information on the shortcodes via: Protect Content > Help > Shortcodes.

    Hope that helps! If you need any further assistance just let us know.

    All the best,
    Tyler

  • Stephen

    OK that is good to know. I am now trying to approach this in a slightly different way.

    I found the account page with that subscription invoice information and I would like to add to that page a table with all previous marketpress orders. It should have similar style and info that the shortcode above spits out (but for physical product orders from Marketpress). What is the best way to go about this?

  • Tyler Postle

    Hey Stephen,

    That would be more difficult, because there is no shortcode for displaying the MP order information. Pages are displayed using templates from the template-functions.php file. You should find the mp order page code in there, you would need to integrate that with the PC account page.

    If you're wanting to hire someone to do this for you then we do have a jobs board for that: https://premium.wpmudev.org/wordpress-development/

    With that said, in the next major release of MarketPress we are aiming to turn the MP pages into physical pages, which would make it a bit easier to achieve something like this :slight_smile: I can put the feature of mp orders shortcode into the feature requests as well.

    Let us know if you have any further questions.

    All the best,
    Tyler

  • Stephen

    So I have the table set up on the PC account page. Now all I need to do is to populate it with the order ids from MP.

    I am hoping you can help me get one piece of data (MP order ids) from one plugin to place on another plugin's page (PC account). I have been searching in the template-functions.php for last few hours and trying different things but can't quite figure it out!

    Considering both are WPMU products, integration should be easily achievable without a custom job I think. After all, I joined the WPMU community for its integration of plugins and support :slight_smile:

  • Tyler Postle

    Hey Stephen,

    Thanks for your reply.

    While we do have a lot of integration between our plugins, not every integration members' request has been developed - and if we developed it on the spot every time then we would be spending all of our time developing and have barely anytime to provide the support part :p

    The large majority of features that do get added to our plugins are based directly off of member requests though :slight_smile:

    I have moved this to the features requests already, so hopefully some other members will chime in wanting the same integration - the more members that want it the more likely it is be included directly in the plugins.

    With all that said, what I can do for you here is call in one of our SLS staff(coding experts) to dig a little deeper into this. Once they have done that then they will post back with some further direction on how to go about achieving this :slight_smile:

    Let us know if you have any further questions in the meantime Stephen! More than happy to help.

    Cheers,
    Tyler

  • Tyler Postle

    No problem Stephen, they should be able to get you going in the right direction here :slight_smile:

    No ETA at the moment, but it is a very high priority. We have unfortunately had some recent delays as you've likely seen in the forums, but it is being worked on as we speak. I can't wait for it to be released!

    Enjoy the rest of your day. SLS will respond here once they have taken a closer look.

    All the best,
    Tyler

  • Hoang Ngo

    Hi @Stephen,

    I hope you are well today.

    The attachment is a plugin, which create a shortcode and you can use that shortcode to display the order detail. Example of usage
    [mp_custom_order_detail order_id=2d47f15bb152]
    For embed it to your Protected Account page, you can do something like that

    add_action('ms_view_account_activity_bottom', 'populate_order_detail');
    function populate_order_detail()
    {
        echo do_shortcode('[mp_custom_order_detail order_id=order_id]');
    }

    But each user will have different order, which mean the variable order_id is various. Can you please let me know how you want to query the orders to display? (display all, latest order etc)

    Please advise,
    Thanks!!!

    Best regards,
    Hoang

  • Hoang Ngo

    Hi @Stephen,

    I hope you are well today.

    Please add this code to your theme functions.php or use mu-plugins

    add_action('ms_view_account_activity_bottom', 'populate_order_detail');
    function populate_order_detail()
    {
        if (!is_user_logged_in()) {
            return '';
        }
        $user_id = get_current_user_id();
        global $mp;
        if (is_object($mp)) {
            $query = new WP_Query(array(
                'post_type' => 'mp_order',
                'post_status' => array('order_paid', 'order_received', 'order_shipped', 'order_closed'),
                'nopaging' => true,
                'author' => $user_id,
            ));
            $orders = $query->posts;
            foreach ($orders as $order) {
                echo do_shortcode('[mp_custom_order_detail order_id=' . $order->post_title . ']');
            }
        }
    }

    Let's see if it can help :slight_smile:

    Best regards,
    Hoang

  • Stephen

    Hi,

    So to recap, I installed the plug-in and added the above longer code snippet to functions.php. I removed the April 16 short code snippet from above as I believe that is redundant with the newer code.

    When I call the shortcode and pass an order id, it displays the order information well. However, it is not practical to 'hard-code' the id into the shortcode as every user's order id will be different. (I did try the shortcode with no id and it didn't produce any content as expected).

    Is this the correct way of implementing your solution or I am doing something wrong?

    Secondly, I tried to just add the populate_order_detail function to my page's php file. That displayed only one order even if the user had multiple orders.

    Lastly, I have been working on my own solution before I heard from you. It seems to work well so far. The only thing I can't populate is the order total. If you think this code is sound (I'm new to PHP) and it would be easier to resolve this way, all I need is to populate order total in the table. Here's the code:

    global $wpdb;
    				$user_ID = get_current_user_id();
     				$oq = $wpdb->get_results("SELECT post_name, post_status, post_date FROM {$wpdb->posts} WHERE post_type = 'mp_order' AND post_author = $user_ID",ARRAY_N);
     				?>
    			    <caption> Product Invoices </caption>
    				<?php if (count($oq) > 0): ?>
    				<table>
    				  <thead>
    				    <tr>
    				      		<td><?php echo "Order #"; ?></td>
    							<td><?php echo "Status"; ?></td>
    							<td><?php echo "Date" ?></td>
    							<td><?php echo "Total (USD)" ?></td>
    				    </tr>
    				  </thead>
    				  <tbody>
    				<?php foreach ($oq as $row): array_map('htmlentities', $row); ?>
    				    <tr>
    				      <td><?php echo implode('</td><td>', $row); ?></td>
                   // I need order total here. Tried inserting $order->mp_order_total but didn't work
    				    </tr>
    				<?php endforeach; ?>
    				  </tbody>
    				</table>
    				<?php endif; ?>
  • Hoang Ngo

    Hi @Stephen,

    I hope you are well today.

    So when you use the latter code I posted (version 2), does the order details show up for you?
    For your version, I think you can do something like this

    function populate_order_detail()
    {
        if (!is_user_logged_in()) {
            return '';
        }
        $user_id = get_current_user_id();
        global $mp;
        if (is_object($mp)) {
            $query = new WP_Query(array(
                'post_type' => 'mp_order',
                'post_status' => array('order_paid', 'order_received', 'order_shipped', 'order_closed'),
                'nopaging' => true,
                'author' => $user_id,
            ));
            $orders = $query->posts;
            echo ' <caption> Product Invoices </caption>';
            foreach ($orders as $raw) {
                $order = $mp->get_order($raw->post_title);
                ?>
                <table>
                    <thead>
                    <tr>
                        <td><?php echo "Order #"; ?></td>
                        <td><?php echo "Status"; ?></td>
                        <td><?php echo "Date" ?></td>
                        <td><?php echo "Total (USD)" ?></td>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td><?php echo $order->post_title ?></td>
                        <td><?php echo implode('<br/>', $order->mp_payment_info['status']) ?></td>
                        <td><?php echo date(get_option('date_format') . ' ' . get_option('time_format'), $order->mp_received_time) ?></td>
                        <td><?php echo $mp->format_currency('', $order->mp_order_total) ?></td>
                    </tr>
                    </tbody>
                </table>
                <?php
            }
        }
    }

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,
    Hoang

  • Stephen

    Hi Hoang,

    I wrote a reply last week but for some reason it didn't appear.First off, your edits to my code worked great so this is now resolved.

    Regarding your question, when I used the latter code I posted (version 2), the order details showed up for the order id I referenced in the short code. However the page needs to dynamically identify the order id (through a variable) rather than 'hard-coding' the id into the shortcode. I probably wasn't using the short code how you imagined in some way.

    Best,
    Stephen

  • Hoang Ngo

    Hi @Stephen,

    I hope you are well today.

    The shortcode will need order_id for querying the data. However, in the version 2 I sent above.

    $query = new WP_Query(array(
                'post_type' => 'mp_order',
                'post_status' => array('order_paid', 'order_received', 'order_shipped', 'order_closed'),
                'nopaging' => true,
                'author' => $user_id,
            ));
            $orders = $query->posts;

    This code block uses for querying the orders belong to current user. And this code block

    foreach ($orders as $order) {
                echo do_shortcode('[mp_custom_order_detail order_id=' . $order->post_title . ']');
            }

    Is for passing the order_id to the shortcode, and display it. This way, you can use it as dynamic without hardcode the order_id parameter.

    But if the version 3 worked for you, so I think we just stick to that plan :wink:

    Best regards,
    Hoang

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.