php - 将 cart.php 和 cart-totals.php 移至结帐页面
问题描述
为了减少我网站上的重定向数量,我在结帐页面上添加了购物车页面。并使用此代码来做到这一点:
function cart_on_checkout_page_only() {
if ( is_wc_endpoint_url( 'order-received' ) ) return;
// add woocomerce cart shortcode on checkout page
echo do_shortcode('[woocommerce_cart]');
}
// Cart and Checkout same page
add_action( 'woocommerce_before_checkout_form', 'cart_on_checkout_page_only', 5 );
问题出在布局上,在设备上它离订单项目太远,因为订单总额位于页面底部靠近结帐按钮的位置。我收到了很多投诉,因为人们懒得向下滚动以查看页面底部购物车中的优惠券应用程序
所以我做了以下修改:
我复制了 woocommerce 插件文件woocommerce/template/cart/cat.php and cart-totals.php
并将其粘贴到我的主题中themes/mytheme/template/cart/custom-cart.php
并在上面的代码中对其进行了修改:
function cart_on_checkout_page_only() {
if ( is_wc_endpoint_url( 'order-received' ) ) return;
// add custom cart template on checkout page
get_template_part('template/cart/custom-cart');
}
// Cart and Checkout same page
add_action( 'woocommerce_before_checkout_form', 'cart_on_checkout_page_only', 5 );
我的代码完成了这项工作,但我相信应该有一种更简单、更优雅的方式来进行这种改变。有可能变得更简单吗?
顺便说一句,我使用的是儿童店面主题。
解决方案
推荐阅读
- flutter - 卡片底部有白条
- ajax - ASPNET CORE Ajax Post 导致 400 错误请求
- angular - 为什么我的 POST 数据没有在 Ionic 4 中正确提交?
- vuejs2 - 在单个文件组件中使用 Mounted 钩子:如何检查 IMG 元素?
- django - Django 默认身份验证视图 URL 没有反向匹配
- git - `origin/master` 是指远程存储库中的远程分支,还是本地存储库中的远程跟踪分支?
- sql - PSQL:使用 JOIN 函数时出现“必须出现在 GROUP BY 子句中或用于聚合函数”错误
- javascript - d3:使用 DataMaps 创建美国地图
- continuum - 在云中运行 Continuum 并在我们的本地 CI 服务器中触发 CI 作业,而无需更改防火墙
- c++ - Boost Spirit - 使用 -O1 而不是 -O2 构建项目