首页 > 解决方案 > 更改单一产品 stock.php woocommerce 会破坏网站,

问题描述

我试图wp-content/plugins/woocommerce/templates/single-product/stock.php通过将其复制到mytheme/woocommerce/single-product/stock.php文件描述中所写的方式来更改 stock.php 文件的样式,但由于某种原因它破坏了网站,现在即使我带回更改或删除错误代码和文件的副本,当在浏览器中打开网页时,我收到消息:

“警告:包括(/homepages/13/d767788347/htdocs/clickandbuilds/Competitions294574/wp-content/plugins/woocommerce/templates/archive-product.php):无法打开流:/homepages/13 中没有这样的文件或目录/d767788347/htdocs/clickandbuilds/Competitions294574/wp-content/plugins/woocommerce/includes/wc-core-functions.php 在第 249 行"

如果副本保留在文件夹中,则错误更改为:

“警告:包括(/homepages/13/d767788347/htdocs/clickandbuilds/Competitions294574/wp-content/plugins/woocommerce/templates/single-product.php):无法打开流:/homepages/13 中没有这样的文件或目录/d767788347/htdocs/clickandbuilds/Competitions294574/wp-includes/template-loader.php 在第 78 行"

我尝试更改颜色的文件如下所示:

<?php
/**
 * Single Product stock.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/single-product/stock.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates
 * @version 3.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

?>
<p class="stock <?php echo esc_attr( $class ); ?>"><?php echo wp_kses_post( $availability ); ?></p>

请帮助我恢复网站并更改显示有多少产品库存的元素的颜色,我还想将文本“X in stock”更改为不同的内容,请问我该怎么做?

标签: phpcsswoocommerce

解决方案


你试过了吗:

1)删除您在主题文件夹中创建的文件/文件夹以覆盖 WooCommerce

2)删除 WooCommerce 并再次上传最新版本 - 如果您有权访问 wp-admin,则从插件更新它(如果您已经使用最新版本,请从 wp-content/plugins/woocommerce/woocommerce 将版本更改为旧版本.php)


推荐阅读