【问题标题】:Change order of cart columns without overriding template files in Woocommerce在 Woocommerce 中更改购物车列的顺序而不覆盖模板文件
【发布时间】:2018-02-23 15:54:19
【问题描述】:

是否有解决方案可以更改购物车列的顺序,而无需将文件复制到我自己的模板文件夹中?

原因是,我不想覆盖这么重要的模板文件。

不幸的是,订单在文件cart.php 中被硬编码为表格,而不是在函数内部。

在这种情况下是否有任何“干净”的方式来改变列的顺序?

【问题讨论】:

  • 好的,谢谢。如果您发布它,我会接受它作为答案

标签: php wordpress templates woocommerce cart


【解决方案1】:

唯一的方法是override Woocommerce cart/cart.php template via your active theme,因为它在模板中是硬编码的。

Woocommerce 模板可以被覆盖,所以这没什么大不了的。

唯一烦人的是,当模板文件在重大更新中发生变化时,如果模板已经更改,您将不得不再次进行更改。

【讨论】:

    【解决方案2】:

    我设法通过设置 grid-template-area grid-template-area on smashingmag 重新排列带有 css 网格的 woocomercerce 列

    这是css代码:

    .woocommerce-cart-form .shop_table tr{
        display: grid;
        grid-template-columns: 120px 40px 1fr 80px 100px 20px; /* change value here to fit your theme  */
        grid-template-areas: "product-thumbnail product-quantity product-name product-price product-subtotal product-remove"; /* change columns order here */
    }
    
    .woocommerce-cart-form .shop_table tr .product-thumbnail{grid-area: product-thumbnail;}
    .woocommerce-cart-form .shop_table tr .product-quantity{grid-area:product-quantity;}
    .woocommerce-cart-form .shop_table tr .product-name{grid-area:product-name;}
    .woocommerce-cart-form .shop_table tr .product-price{grid-area:product-price;}
    .woocommerce-cart-form .shop_table tr .product-subtotal{grid-area:product-subtotal;}
    .woocommerce-cart-form .shop_table tr .product-remove{grid-area:product-remove;}
    

    ⚠︎不要忘记在手机上查看!

    【讨论】:

      猜你喜欢
      • 2017-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-29
      相关资源
      最近更新 更多