【问题标题】:PhP file to edit, but unfamiliar with phpphp文件要编辑,但对php不熟悉
【发布时间】:2010-09-17 15:23:29
【问题描述】:

我想将附属脚本与购物车集成,

为此我需要编辑 2 个 php 文件,但本教程对我来说并不容易,因为我不熟悉 php。

例如:

打开“wp_eStore1.php”文件,找到如下函数:

功能 eStore_get_custom_field_value()

一旦你找到它,只需添加 跟随接近尾声 函数(就在返回之前 声明):

$name = 'jrox_cookie';
$value = $_COOKIE['jrox'];
$custom_field_val = append_values_to_custom_field($name,$value);

我应该在 wp_eStore1.php 哪里添加这 3 行?

这是该文件的源代码:http://pastebin.com/nwZixJZa 该函数位于第 676 行

谢谢

【问题讨论】:

  • 你找到了这个功能。你看到那个函数的返回语句了吗?在 return 语句之前添加这些行。
  • 我不知道什么是返回语句,这是我的问题 :) 只需要知道自己进行编辑会是什么样子,谢谢
  • return 语句是一个单词 return 后跟一个变量。

标签: php


【解决方案1】:

它要求您将这 3 行放在 return 语句之前(位于第 708 行)。

【讨论】:

    【解决方案2】:

    像这样:

    function eStore_get_custom_field_value()
    {
    
            $output = '';
    
            $_SESSION['eStore_custom_values']='';
    
            if (!empty($_SESSION['ap_id']))
    
            {
    
            $name = 'ap_id';
    
            $value = $_SESSION['ap_id'];
    
            $custom_field_val = append_values_to_custom_field($name,$value);
    
            }
    
            else if (isset($_COOKIE['ap_id']))
    
            {
    
            $name = 'ap_id';
    
            $value = $_COOKIE['ap_id'];
    
            $custom_field_val = append_values_to_custom_field($name,$value);
    
            }
    
            if (!empty($_SESSION['eStore_coupon_code']))
    
            {
    
            $name = 'coupon';
    
            $value = $_SESSION['eStore_coupon_code'];
    
            $custom_field_val = append_values_to_custom_field($name,$value);
    
        }
    
        if (function_exists('wp_eMember_install'))
    
        {  
    
                global $auth;
                $user_id = $auth->getUserInfo('member_id');
    
                if (!empty($user_id))
                {
                            $name = 'eMember_id';
                            $custom_field_val = append_values_to_custom_field($name,$user_id);
                }
        }  
        /* HERE ARE YOUR LINES */
        $name = 'jrox_cookie';
        $value = $_COOKIE['jrox'];
        $custom_field_val = append_values_to_custom_field($name,$value);
    
        return $custom_field_val;
    }
    

    :)

    【讨论】:

      【解决方案3】:

      好吧,第 676 行包含了包含在 { 和 } 之间的函数定义(第 677 - 709 行)。在该定义的末尾有一个返回语句:return $custom_field_val;。在该行之前插入您的代码。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-05-11
        • 1970-01-01
        • 2017-08-03
        • 2016-09-22
        • 2010-10-08
        • 1970-01-01
        • 2011-01-06
        • 1970-01-01
        相关资源
        最近更新 更多