如何修改WooCommerce购物车,结帐页面(主要主题部分) [英] How to modify WooCommerce cart, checkout pages (main theme portion)

查看:1028
本文介绍了如何修改WooCommerce购物车,结帐页面(主要主题部分)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究和调整我的自定义Wordpress主题和覆盖的WooCommerce模板,现在安装了WooCommerce来纠正WooCommerce页面上出现的一些小格式问题.我现在到了购物车和结帐处,是的,他们使用cart.php(以及任何结帐php),但也使用了主要的Wordpress主题page.php.我已经可以在其他有条件的地方使用is_woocommerce()了,但是不能在这里使用,因为我了解到WooCommerce文档说不能在结帐和购物车上使用.

I have been researching and tweaking away at my custom Wordpress theme and overridden WooCommerce templates with now WooCommerce installed to rectify a bunch of small formatting issues that occur on the WooCommerce pages. I'm down to now the cart and checkout, which yeah they use cart.php (and whatever checkout php), but also uses the main Wordpress theme page.php. I've been able to use is_woocommerce() in conditionals other places but not here as I've learned the WooCommerce docs say that can't be used on checkout and cart.

is_woocommerce()-如果在使用WooCommerce模板的页面上(购物车和结帐是带有短代码的标准页面,因此不包括在内),则返回true. http://docs.woothemes.com/document/conditional-tags/

is_woocommerce() - Returns true if on a page which uses WooCommerce templates (cart and checkout are standard pages with shortcodes and thus are not included). http://docs.woothemes.com/document/conditional-tags/

那么我该如何更改这些页面的外观?我在顶部有一个查看所有帖子",并有一个日期/时间,而page.php的类别侧边栏由于明显的原因我不想在结帐和购物车上显示,因为它们根本没有意义.我有什么选择?

So how can I alter the appearance of these pages? I have a "View All Posts" and a date/time at the top, and categories sidebar of page.php that I don't want showing up for obvious reasons on the checkout and cart since they don't make sense at all. What are my options?

我可以使它使用除page.php之外的其他模板吗?

Can I make it use a different template other than page.php?

这是一个选择吗?这是不好的做法吗?是否会导致此循环在每个页面上产生更多负载?我放在哪里? http://saiyedfaishal.wordpress.com/2014/01/06/check-if-it-is-woocommerce-page/

Is this an option? Is it bad practice... does it cause more load on every page with this loop? Where do I put it? http://saiyedfaishal.wordpress.com/2014/01/06/check-if-it-is-woocommerce-page/

解决此问题的最佳方法是什么?谢谢你的帮助! 这个问题与-如何修改woocommerce_before_cart动作 >

What's the best way to go about this? Thanks for any help! This question is somewhat related to - How to modify woocommerce_before_cart action

推荐答案

您可以使用函数: wc_get_page_id( 购物车")以获取页面的ID.此功能会将页面设置用作购物车"页面,而不是子页面.这意味着当您在设置页面上为购物车"设置其他网址时,它也将继续起作用.这适用于所有Woocommerce特殊页面,例如结帐",商店"等.

You can use function: wc_get_page_id( 'cart' ) to get the ID of the page. This function will use the page setup as 'cart' page and not the slug. Meaning it will keep working also when you setup a different url for your 'cart' on the settings page. This works for all kind of Woocommerce special page, like 'checkout', 'shop' etc.

示例:

if (wc_get_page_id( 'cart' ) == get_the_ID()) {
  // Do something.
}

这篇关于如何修改WooCommerce购物车,结帐页面(主要主题部分)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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