如何显示用户的 WooCommerce 订阅详细信息? [英] How to display user's WooCommerce subscription details?

查看:34
本文介绍了如何显示用户的 WooCommerce 订阅详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义页面模板,我想显示用户订阅的特定详细信息(例如订阅开始日期).

I have created a custom page template and I want to display specific details of user's subscription (e.g. subscription starting date).

我的帐户"页面上的可用钩子显示了这一点,但我不知道如何拆除钩子的输出,甚至只是将其显示在页面模板上.

The available hook on 'my account' page displays this but I don't know how to dismantle the output of the hook or even merely displaying it on a page template.

任何帮助将不胜感激!

推荐答案

在活动主题的functions.php中添加如下代码

Add the following code in functions.php of the active theme.

add_shortcode('wdm_my_subscription', 'wmd_my_custom_function');
function wmd_my_custom_function(){
    WC_Subscriptions::get_my_subscriptions_template();
}

现在在要显示用户订阅的页面上使用 [wdm_my_subscription] 作为短代码.

Now use [wdm_my_subscription] as a shortcode on the page where you want to display the User's subscription.

截图:

没有简码:

添加短代码:

结果:

如果您需要修改此输出,您可能需要复制 WooCommerce 订阅插件的 get_my_subscriptions_template() 函数 WC_Subscriptions 类的包含并在此使用它代替短代码,它可以帮助您添加所需的详细信息.

If you need to modify the output of this you might need to copy the contains of get_my_subscriptions_template() function WC_Subscriptions class of the WooCommerce subscription Plugin and use it in this shortcode instead which will help you to add the details you want.

这篇关于如何显示用户的 WooCommerce 订阅详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆