php - 更改单一产品 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”更改为不同的内容,请问我该怎么做?
解决方案
你试过了吗:
1)删除您在主题文件夹中创建的文件/文件夹以覆盖 WooCommerce
2)删除 WooCommerce 并再次上传最新版本 - 如果您有权访问 wp-admin,则从插件更新它(如果您已经使用最新版本,请从 wp-content/plugins/woocommerce/woocommerce 将版本更改为旧版本.php)
推荐阅读
- javascript - jsPDF 和 html2canvas 图像被压扁了?
- google-apps-script - 使用 Colab 读取 gscript 文件
- java - 使用 DFS 回溯算法生成迷宫的问题
- gradle - 运行 byfn 时出错:由于 gradle 问题导致链码安装失败?
- python - 有没有办法让 cvxpy 超时
- php - 在 PHP foreach 的脚本中回显 JSON.parse 时,如何避免语法错误?
- jmeter - Jmeter如何在各个线程之间分配互联网速度?
- jquery - 如何使用 Jquery 代码在 Excel 中连续添加数据
- python - 我想看看什么时候在 Hangman 中发现了所有的字母,但它只是不起作用
- python - 在 python 中制作考试评分器 [列出相关问题]