小编ptr*_*cao的帖子

将条件添加到mustache / php

考虑:

<?php
/**
 * Single variation display
 *
 * This is a javascript-based template for single variations (see https://codex.wordpress.org/Javascript_Reference/wp.template).
 * The values will be dynamically replaced after selecting attributes.
 *
 * @see     https://docs.woocommerce.com/document/template-structure/
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 2.5.0
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}
?>
<script type="text/template" id="tmpl-variation-template">
    <div class="woocommerce-variation-description">{{{ data.variation.variation_description }}}</div>

    <div class="woocommerce-variation-price">{{{ data.variation.price_html }}}</div>

    <div class="woocommerce-variation-availability">{{{ data.variation.availability_html }}}</div>

 <div class="woocommerce-variation-custom-text-field">
        GTIN: <span class="sku">{{{ data.variation.wccaf_gtin }}}</span>
    </div>

 <div class="woocommerce-variation-custom-text-field">
        MPN: …
Run Code Online (Sandbox Code Playgroud)

javascript php wordpress mustache mustache.php

7
推荐指数
1
解决办法
173
查看次数

致命错误:未捕获错误:调用未定义的函数 is_product()

将我的生产 WordPress 相关网站导入到本地 Xampp 环境后,出现以下错误:

致命错误:未捕获错误:调用 C:\xampp\htdocs\public_html\siliconharvest\wp-content\themes\storefront-child\functions.php:62 中未定义的函数 is_product() 堆栈跟踪:#0 C:\xampp\ htdocs\public_html\siliconharvest\wp-includes\class-wp-hook.php(286): wc_variable_simple_conditions('') #1 C:\xampp\htdocs\public_html\siliconharvest\wp-includes\class-wp-hook.php (310): WP_Hook->apply_filters(NULL, Array) #2 C:\xampp\htdocs\public_html\siliconharvest\wp-includes\plugin.php(453): WP_Hook->do_action(Array) #3 C:\xampp \htdocs\public_html\siliconharvest\wp-includes\general-template.php(2614): do_action('wp_head') #4 C:\xampp\htdocs\public_html\siliconharvest\wp-content\themes\storefront\header.php (18): wp_head() #5 C:\xampp\htdocs\public_html\siliconharvest\wp-includes\template.php(688): require_once('C:\xampp\htdocs...') #6 C:\ xampp\htdocs\public_html\siliconharvest\wp-includes\template.php(647): load_template('C:\xampp\htdocs...', true) #7 C:\xampp\htdocs\public_html\siliconharvest\wp-包括 \general-template.php( 在 C:\xampp\htdocs\public_html\siliconharvest\wp-content\themes\storefront-child\functions.php 第 62 行

我已尝试以下诊断步骤,但对错误没有影响:

  1. 禁用所有插件,包括与产品相关的插件(Woocommerce)
  2. 重命名了 storefront-child\functions.php 文件(暂时禁用它)
  3. 将模板更改为 store-front child 以外的内容

然而,无论执行上述任何步骤,错误仍然存​​在。正确的解决方案必须使所有这些错误消失。

编辑:错误中引用的functions.php文件的第1-73行:

<?php
// BEGIN Remove "Storefront Designed by WooThemes" from Footer as per https://danielsantoro.com/remove-storefront-designed-woothemes/
add_action('init', 'custom_remove_footer_credit', 10);
function custom_remove_footer_credit()
{
    remove_action('storefront_footer', 'storefront_credit', 20);
    add_action('storefront_footer', 'custom_storefront_credit', …
Run Code Online (Sandbox Code Playgroud)

php debugging wordpress woocommerce

5
推荐指数
2
解决办法
2万
查看次数

将数组传递给in_array()

请考虑以下PHP:

function get_ship_class()
{
    $csv = array_map("str_getcsv", file("somefile.csv", "r")); 
    $header = array_shift($csv); 

    // Seperate the header from data
    $col = array_search("heavy_shipping_class", $header); 

    foreach ($csv as $row)
    {      
        $array[] = $row[$col]; 
    }
}
Run Code Online (Sandbox Code Playgroud)

如何将上述函数中生成的数组传递给

if( in_array() ){
    //code
}
Run Code Online (Sandbox Code Playgroud)

php arrays

0
推荐指数
1
解决办法
96
查看次数