バージョン選択

フォーラム

メニュー

オンライン状況

66 人のユーザが現在オンラインです。 (54 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 66
もっと...

サイト内検索

質問 > フロント機能 > 《初心者です》商品詳細ページにオプションを追加したい。

フロント機能

新規スレッドを追加する

スレッド表示 | 古いものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
yuh
投稿日時: 2015/2/26 20:57
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1819
Re: 《初心者です》商品詳細ページにオプションを追加したい。
○○ファイルの△△行目付近(以前)で、オブジェクトに関連付けられていないメンバー関数を呼び出したことによる、致命的エラー

エラーメッセージ
Fatal error: Call to a member function **() on a non-object in ○○ on line △△


まずはPHPの基本的な事から調べてください。
mom
投稿日時: 2015/2/26 19:05
対応状況: −−−
半人前
登録日: 2015/2/17
居住地: 京都
投稿: 16
Re: 《初心者です》商品詳細ページにオプションを追加したい。
エラーログ

引用:
Call to a member function getCartProductID() on a non-object on [/Applications/MAMP/htdocs/test3/data/class/pages/products/LC_Page_Products_Detail.php(220)] from ::1
customer_id =


と出ていますので、

SC_CartSession.php内のgetCartProductID()がこちらに対応していると言う事で宜しいのでしょうか。

function getCartProductID($cartKey) {
// カートキーの最大要素番号を取得する
$max = $this->getMax($cartKey);
// 全てのカートに含まれている商品IDを取得する
for($i = 0; $i <= $max; $i++) {
if($this->cartSession[$cartKey][$i]['cart_no'] != "") {
$arrRet[] = $this->cartSession[$cartKey][$i]['productsClass']['product_id'];
}
}
return $arrRet;
}

となっています。
この場合どういった対応を行えば良いのでしょうか。
yuh
投稿日時: 2015/2/26 18:44
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1819
Re: 《初心者です》商品詳細ページにオプションを追加したい。
Call to a member function等のエラーログを調べてください
mom
投稿日時: 2015/2/26 17:18
対応状況: −−−
半人前
登録日: 2015/2/17
居住地: 京都
投稿: 16
Re: 《初心者です》商品詳細ページにオプションを追加したい。
現在商品詳細ページにオプションを作成しようとして、トライしています。

http://itoben.com/blog/551.html
こちらのページ通り、
dtp_products
dtb_order
dtb_order_temp
にカラム追加

マスターテーブルを2つ追加

mtb_constantsにカラムを追加

を行い
data/class/SC_CartSession.php
data/class/helper/SC_Helper_DB.php

管理画面
data/class/page/admin/products/LC_Page_Admin_Products_Product.php
data/Smarty/templates/admin/products/product.tpl
data/Smarty/templates/admin/products/confirm.tpl

に登録完了

次、商品購入/お支払い方法・お届け時間等の指定ページにプルダウンメニューを掲載するため、

data/class/pages/shopping/LC_Page_Shopping_Payment.php
こちらで
function init()
function action()
function lfInitParam
をカスタマイズ

data/Smarty/templates/default/shopping/payment.tpl
data/class/pages/shopping/LC_Page_Shopping_Confirm.php
に呼び出し

これでうまくいきましたので、
同等の物を商品詳細ページに移行しようと思い、

LC_Page_Produsts_Detail.php
にて同じく
function init()
function action()
function lfInitParam
をカスタマイズ

data/Smarty/templates/default/protucts/detail.tplもカスタマイズしたのですが、

以下のエラーコードが出てしまいます。

引用:
2015/02/26 17:04:35 [/test3/products/detail.php] Fatal error(E_ERROR): Call to a member function getCartProductID() on a non-object on [/Applications/MAMP/htdocs/test3/data/class/pages/products/LC_Page_Products_Detail.php(220)] from ::1
customer_id =



LC_Page_Products_Detail.php(220)には
引用:
$this->gift_paper_flg = $objDb->sfJudgeShowGiftPaper($objCartSess->getCartProductID($this->cartKey));

この様に記されています。

こちらの文を、
$this->gift_paper_flg = $objDb->sfJudgeShowGiftPaper($this->arrForm['product_id']['value']);
この様に変更したらデータベースのエラーになりました。

class LC_Page_Products_Detail extends LC_Page_Ex内には
引用:
public $arrGIFTPAPER;

も追加しています。

SC_CartSession.phpの対応する箇所としては、
function getCartProductID($cartKey) {
// カートキーの最大要素番号を取得する
$max = $this->getMax($cartKey);
// 全てのカートに含まれている商品IDを取得する
for($i = 0; $i <= $max; $i++) {
if($this->cartSession[$cartKey][$i]['cart_no'] != "") {
$arrRet[] = $this->cartSession[$cartKey][$i]['productsClass']['product_id'];
}
}
return $arrRet;
}

この様になっています。


もう、一息と言う所まで来たので、なんとか実現させたいです。
何卒、ご教授ください。宜しくお願いいたします。
mom
投稿日時: 2015/2/26 17:06
対応状況: −−−
半人前
登録日: 2015/2/17
居住地: 京都
投稿: 16
Re: 《初心者です》商品詳細ページにオプションを追加したい。
yuh様、ありがとうございました。勉強になりました。
現在違う方法でトライしています。が、またエラーになってしまいました。配送情報・お支払いのページに掲載する事は出来たのですが。それを商品詳細ページに移行する際にエラーになってしまいます。

yuh
投稿日時: 2015/2/24 23:57
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1819
Re: 《初心者です》商品詳細ページにオプションを追加したい。
smallintでフィールド作ってるのに

$objFormParam->addParam('目的', 'mokuteki_set', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
が文字列です。

$objFormParam->addParam('目的', 'mokuteki_set', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
と変更してippitsu_setがないので
$objFormParam->addParam('目的', 'ippitsu_set', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
これも追加してください


$mokuteki = $this->arrMOKUTEKI[$this->objFormParam->getValue('mokuteki_set')];
$ippitsu = $this->arrIPPITSU[$this->objFormParam->getValue('ippitsu_set')];
と書かれてるので、文字列で入るはずです。
なので
$mokuteki = $this->objFormParam->getValue('mokuteki_set');
$ippitsu = $this->objFormParam->getValue('ippitsu_set');

と変更してください

$objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'), $mokuteki, $ippitsu);
で渡してるのに
public function addProduct($product_class_id, $quantity,$mokuteki=NULL)
となっているので

public function addProduct($product_class_id, $quantity,$mokuteki=NULL,ippitsu = NULL)
と変更してください。

とりあえずコピペして追加してみました→デバッグしてください
っていうのはどうなんでしょう・・・。

無理でしたらインテグレートパートナーの会社様にご依頼するのがよろしいかと思います。
mom
投稿日時: 2015/2/24 22:45
対応状況: −−−
半人前
登録日: 2015/2/17
居住地: 京都
投稿: 16
Re: 《初心者です》商品詳細ページにオプションを追加したい。
yuh様
度々ありがとうございます。
何度、試行錯誤してもデータが入りませんでした。

以下長文になりますが、ご覧頂けたとして、解決策はございますでしょうか。
素人ながらもカスタマイズ挑戦の限界と行った感じで、ヒント等ご教授頂けましたら、幸いです。
何卒、宜しくお願いいたします。

detail.tpl
引用:
<!--{* 【追加】 *}-->
<div class="clearfix form-group<!--{if $arrErr.mokuteki_set != ""}--> has-error<!--{/if}-->">
<label for="mokuteki_set" class="col-sm-5 control-label">目的:</label>
<div class="col-sm-7">
<select id="mokuteki_set" class="form-control" name="mokuteki_set" style="<!--{$arrErr.mokuteki_set|sfGetErrorColor}-->">
<!--{html_options options=$arrMOKUTEKI selected=$arrForm.mokuteki_set.value}-->
</select>
<!--{if $arrErr.mokuteki_set != ""}-->
<br /><label class="attention" for="mokuteki_set">※ 配置を入力して下さい。</label>
<!--{/if}-->



LC_Page_Products_Detail.php 該当箇所


引用:
public function doCart()
{
$this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam,
$this->tpl_classcat_find1,
$this->tpl_classcat_find2);
if (count($this->arrErr) == 0) {
$objCartSess = new SC_CartSession_Ex();
$product_class_id = $this->objFormParam->getValue('product_class_id');



//【追記】
$mokuteki = $this->arrMOKUTEKI[$this->objFormParam->getValue('mokuteki_set')];
$ippitsu = $this->arrIPPITSU[$this->objFormParam->getValue('ippitsu_set')];
//【追記】
$objCartSess->addProduct($product_class_id, $this->objFormParam->getValue('quantity'), $mokuteki, $ippitsu);


引用:
/** 目的 */
public $arrMOKUTEKI; //【追記】


引用:
$this->arrMOKUTEKI = $masterData->getMasterData('mtb_mokuteki'); //【追記】


引用:
$objFormParam->addParam('目的', 'mokuteki_set', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK'));



SC_CartSession.php


引用:
// カートへの商品追加
public function addProduct($product_class_id, $quantity,$mokuteki=NULL)
{
$objProduct = new SC_Product_Ex();
$arrProduct = $objProduct->getProductsClass($product_class_id);
$productTypeId = $arrProduct['product_type_id'];
$find = false;
$max = $this->getMax($productTypeId);
for ($i = 0; $i <= $max; $i++) {
if ($this->cartSession[$productTypeId][$i]['id'] == $product_class_id) {
$val = $this->cartSession[$productTypeId][$i]['quantity'] + $quantity;
if (strlen($val) <= INT_LEN) {
$this->cartSession[$productTypeId][$i]['quantity'] += $quantity;
}
$find = true;
}
}
if (!$find) {
$this->cartSession[$productTypeId][$max+1]['id'] = $product_class_id;
$this->cartSession[$productTypeId][$max+1]['quantity'] = $quantity;
$this->cartSession[$productTypeId][$max+1]['cart_no'] = $this->getNextCartID($productTypeId);
//【追記】
$this->cartSession[$productTypeId][$max+1]['mokuteki_set'] = $mokuteki;
$this->cartSession[$productTypeId][$max+1]['ippitsu_set'] = $ippitsu;
}
}


引用:
public function adjustSessionProductsClass(&$arrProductsClass)
{
$arrNecessaryItems = array(
'product_id' => true,
'product_class_id' => true,
'name' => true,
'price02' => true,
'point_rate' => true,
'main_list_image' => true,
'main_image' => true,
'product_code' => true,
'stock' => true,
'stock_unlimited' => true,
'sale_limit' => true,
'class_name1' => true,
'classcategory_name1' => true,
'class_name2' => true,
'classcategory_name2' => true,
'mokuteki_set' => true,
'ippitsu_set' => true,
//【追記】


LC_Page_Cart.php
引用:
$objFormParam->addParam('目的', 'mokuteki_set', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK'));


SC_Helper_Purchase.php
引用:
// 詳細情報を生成
$objProduct = new SC_Product_Ex();
$i = 0;
$arrDetail = array();
foreach ($cartItems as $item) {
$p =& $item['productsClass'];
$arrDetail[$i]['order_id'] = $orderParams['order_id'];
$arrDetail[$i]['product_id'] = $p['product_id'];
$arrDetail[$i]['product_class_id'] = $p['product_class_id'];
$arrDetail[$i]['product_name'] = $p['name'];
$arrDetail[$i]['product_code'] = $p['product_code'];
$arrDetail[$i]['classcategory_name1'] = $p['classcategory_name1'];
$arrDetail[$i]['classcategory_name2'] = $p['classcategory_name2'];
$arrDetail[$i]['point_rate'] = $item['point_rate'];
$arrDetail[$i]['price'] = $item['price'];
$arrDetail[$i]['quantity'] = $item['quantity'];
$arrDetail[$i]['tax_rate'] = $item['tax_rate'];
$arrDetail[$i]['tax_rule'] = $item['tax_rule'];
$arrDetail[$i]['tax_adjuts'] = $item['tax_adjust'];
$arrDetail[$i]['mokuteki_set'] = $item['mokuteki_set']; //【追記】
$arrDetail[$i]['ippitsu_set'] = $item['ippitsu_set']; //【追記】


引用:
public function getOrderDetail($order_id, $has_order_status = true)
{
$objQuery =& SC_Query_Ex::getSingletonInstance();
$dbFactory = SC_DB_DBFactory_Ex::getInstance();
$col = <<< __EOS__
T3.product_id,
T3.product_class_id as product_class_id,
T3.product_type_id AS product_type_id,
T2.product_code,
T2.product_name,
T2.classcategory_name1 AS classcategory_name1,
T2.classcategory_name2 AS classcategory_name2,
T2.mokuteki_set,//【追記】
T2.ippitsu_set,//【追記】


confirm.tpl
引用:
<!--{* 【追加】 *}-->
<!--{if $item.mokuteki_set != ""}-->
<li><small>目的:<!--{$item.mokuteki_set|h}--></small></li>
<!--{/if}-->
<!--{if $item.ippitsu_set != ""}-->
<li><small>一筆箋:<!--{$item.ippitsu_set|h}--></small></li>
<!--{/if}-->


ちなみにデータベースは

dtb_productsに
引用:
mokuteki smallint NULLいいえ 2
ippitsu smallint NULLいいえ 2


dtb_order_detailに
引用:
mokuteki_set smallint NULLいいえ なし
ippitsu_set smallint NULLいいえ なし


mtb_mokutekiに
引用:

id smallint NULLいいえ 0
name text NULLはい NULL
rank smallint NULLいいえ 0


を作成しています。

ここまでが現在の私のカスタマイズになります。

宜しくお願いいたします。
yuh
投稿日時: 2015/2/24 22:02
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1819
Re: 《初心者です》商品詳細ページにオプションを追加したい。
その部分はSESSIONで受け渡しがされるはずなので、うまく入ってないんじゃないかとおもいます。
mom
投稿日時: 2015/2/24 21:07
対応状況: −−−
半人前
登録日: 2015/2/17
居住地: 京都
投稿: 16
Re: 《初心者です》商品詳細ページにオプションを追加したい。
detail.tplにて、
<!--{$arrErr|@debug_print_var}--> = NULL

<!--{$arrMOKUTEKI|@debug_print_var}--> = Array (2)

<!--{$arrForm|@debug_print_var}--> =mokuteki_set => Array (4)

cart/index.tplにて
<!--{$item|@debug_print_var}--> = mokuteki_set => null
ippitsu_set => null

ここのitemに値が受け渡されていないのが原因な様です。

おそらく、該当はSC_Helper_Purchase.phpだと思うのですが、
public function registerOrderComplete
下に
foreach ($cartItems as $item) {

・・・

$arrDetail[$i]['mokuteki_set'] = $item['mokuteki_set']; //【追記】
$arrDetail[$i]['ippitsu_set'] = $item['ippitsu_set']; //【追記】

こちらを入れているのに、データが受け渡しされていない、という事なのでしょうか。。


dumpを知って、ページ間のつながりが見えてきました。ありがとうございます。
yuh
投稿日時: 2015/2/24 19:56
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1819
Re: 《初心者です》商品詳細ページにオプションを追加したい。
どこまで値が入っているかを順にチェックしていった方がいいと思います。
(1) 2 »
スレッド表示 | 古いものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は89,027名です
総投稿数は110,020件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2314
5
umebius
2085
6
yuh
1819
7
h_tanaka
1646
8
red
1570
9
mcontact
1296
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.