我在云中有一台具有以下功能的服务器: Centos的7.2 Opencart 3.0.2
我正在创建一个名为Delivery的新类,我从/ catalog / model / checkout / order / addOrder调用其功能之一
我命令它这样调用:
$ date_delivery = $ this-> customer-> termFinal ($ day, $ month, $period);
此新类从天月份和交货天数计算订单的交货时间。 我收到以下错误:
Fatal error: Uncaught Error: Call to a member function
getCustomerConfiguration () on null in
/var/www/html/system/library/cart/customer.php:742 Stack trace: # 0 / var
/ www / html / catalog / model /checkout/order.php(409): Cart \ Customer->
termFinal ('16 ',' 10 ',' 2 ')
# 1 / var / www / html / system / storage / modification / system / engine / loader. php (248): ModelCheckoutOrder-> updateOrderAuth (Array)
# 2 /var/www/html/system/engine/proxy.php(47): Loader -> {closure} (Array, Array)
# 3 / var / www / html / catalog / controller / account / order_auth.php (516): Proxy -> __ call ('updateOrderAuth', Array)
# 4 /var/www/html/system/storage/modification/system/engine/action.php(79 ): ControllerAccountOrderAuth-> update ()
# 5 /var/www/html/catalog/controller/startup/router.php(25): Action-> execute (Object (Registry))
# 6 / var / www / html / system /storage/modification/system/engine/action.php(79): ControllerStartupRouter-> index ()
# 7 /var/www/html/system/engine/router.php(72): Action-> execute (Object (Registry ))
# 8 /var/www/html/system/engine/router.php(61): Router-> execute (Object (Action))
# 9 / v in /var/www/html/system/library/cart/customer.php on line 742
getCustomerConfiguration()函数指向该类:库/购物车/购物车
这是Delivery类的一部分:
namespace Cart;
class Delivery {
private $ anio;
private $ holidays;
private $ holidays Mobile = array ();
private $ holidays = array ();
private $ dateDelivery;
public function __construct ($ registry) {
$ this-> config = $ registry-> get ('config');
$ this-> customer = $ registry-> get ('customer');
$ this-> cart = $ registry-> get ('cart');
$ this-> session = $ registry-> get ('session');
$ this-> db = $ registry-> get ('db');
$ this-> tax = $ registry-> get ('tax');
$ this-> cart-> getCustomerConfiguration (); <=== THIS IS THE FUNCTION
$ anio = date ("Y");
$ holidays = ($ this-> session-> data ['holidays'])? $ this-> session-> data ['holidays']: 0;
(! empty ($ anio))? $ this-> anio = (int) ($ anio): null;
(! empty ($ holidays))? $ this-> holidays = explode (",", $ holidays): null;
if (! empty ($ holidays)) {
foreach ($ this-> holidays as $ date) {
$ this-> holidays [] = $ date. "-". $ this-> anio;
}
}
// Thursday and Good Friday
$ date = explode ('-', $ this-> jvSanto ($ this-> anio));
$ this-> holidays [] = date ("j-n-Y", mktime (0,0,0, $ date [1], $ date [0] -3, $ date [2]));
$ this-> holidays [] = date ("j-n-Y", mktime (0,0,0, $ date [1], $ date [0] -2, $ date [2]));
// I add Mobile Holidays
foreach ($ this-> feriadosMoviles as $ fecha) {
for ($ f = $ this-> anio; $ f <($ this-> anio + 1); $ f ++) {
$ holiday = $ date. "-". $ f;
$ diaFeriado = $ this-> getDiaSemana ($ holiday);
// $ dia = $ diaFeriado ['dia'];
// $ correction = 0;
$ this-> holidays [] = $ this-> getStringDate ($ diaFeriado ['unix']);
}
}
}
答案 0 :(得分:0)
您已经分配了$ this-> cart
:
$ this-> cart = $ registry-> get ('cart');