我正在开发一个插件,用于将额外的支付提供商“挂钩”到一个结账系统。
我的函数中有一个类gtpCheckoutData。计算价格的php。
在我的插件中,我想使用这个类中的数据,但如果这样做,我会得到:
Fatal error: Class gtpCheckoutData not found in
我的插件代码:class gtpMollieGateway {
private $mollie, $price;
function __construct() {
$this->mollie = new Mollie_API_Client;
// THIS IS THE PROBLEM
$this->price = new gtpCheckoutData;
add_action( \'init\', array( $this, \'gtpCreatePayment\' ) );
}
function gtpCreatePayment() {
if( isset( $_POST[\'checkout_submit\'] ) ) {
$payment = $this->mollie->payments->create(array(
\'amount\' => $this->price->getPrice( \'inclusive\' ),
));
header( "Location: " . $payment->getPaymentUrl() );
}
}
}
函数中的My类。phpclass gtpCheckoutData {
private $tax, $price;
public function __construct() {
$this->tax = get_gtp_option( \'gtp_tax\' ) / 100;
$this->price = $_SESSION[\'shopping_cart\'][\'total_price\'] + $_SESSION[\'shopping_cart\'][\'shipping_price\'];
$this->shipping = $_SESSION[\'shopping_cart\'][\'shipping_price\'];
}
public function getPrice( $type ) {
if( isset( $type ) ) {
switch( $type ) {
case \'exclusive\' :
$totalPrice = $this->price;
break;
case \'tax\' :
$totalPrice = $this->price * $this->tax;
break;
case \'inclusive\' :
$totalPrice = $this->price * ( $this->tax + 1 );
break;
}
return $totalPrice;
}
}
}