How to get “Terms & Conditions” Page ID in WooCommerce?

狂风中的少年 提交于 2021-02-11 17:17:17

问题


I'd like to know how to get the page which set as "Terms & Conditions Page" on "Appearance > Customize > WooCommerce > Checkout" on WordPress admin.

I could get privacy policy page with "is_privacy_policy()", but don't know how to get "Terms & Conditions Page".

I want to do this to make a plugin for WooCommerce not just for me but any person, so I can not know its page slug.

Thank you.


回答1:


First terms and conditions WordPress page need to be defined in WooCommerce Settings > Advanced > Terms and conditions field…

Then you can get the "terms and conditions" page ID (and page) using:

$page_id = wc_terms_and_conditions_page_id();
$page    = $page_id ? get_post( $page_id ) : false;


来源:https://stackoverflow.com/questions/63333105/how-to-get-terms-conditions-page-id-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!