且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何显示用户的 WooCommerce 订阅详细信息?

更新时间:2023-12-04 10:04:46

在活动主题的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.