本文整理汇总了PHP中hikashopPaymentPlugin::listPlugins方法的典型用法代码示例。如果您正苦于以下问题:PHP hikashopPaymentPlugin::listPlugins方法的具体用法?PHP hikashopPaymentPlugin::listPlugins怎么用?PHP hikashopPaymentPlugin::listPlugins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hikashopPaymentPlugin
的用法示例。
在下文中一共展示了hikashopPaymentPlugin::listPlugins方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBeforeOrderCreate
function onBeforeOrderCreate(&$order, &$do)
{
if (!empty($order->order_type) && $order->order_type != 'sale') {
return true;
}
if (empty($order->order_payment_params)) {
$order->order_payment_params = new stdClass();
}
if (empty($order->order_payment_params->userpoints)) {
$order->order_payment_params->userpoints = new stdClass();
}
if (empty($order->order_payment_params->userpoints->use_points)) {
$order->order_payment_params->userpoints->use_points = 0;
}
if (empty($order->order_payment_params->userpoints->earn_points)) {
$order->order_payment_params->userpoints->earn_points = array();
}
$earnPoints = $this->getPointsEarned($order, 'all');
if (!empty($earnPoints)) {
foreach ($earnPoints as $mode => $pts) {
if (empty($order->order_payment_params->userpoints->earn_points[$mode])) {
$order->order_payment_params->userpoints->earn_points[$mode] = 0;
}
$order->order_payment_params->userpoints->earn_points[$mode] += $pts;
}
}
if ((empty($order->order_payment_method) || $order->order_payment_method != $this->name) && !empty($order->cart->additional)) {
$ids = array();
parent::listPlugins($this->name, $ids, false);
foreach ($ids as $id) {
parent::pluginParams($id);
if (empty($this->payment_params)) {
continue;
}
if ($this->payment_params->virtual_coupon) {
$checkPoints = $points = $this->checkPoints($order);
$usePts = -1;
foreach ($order->cart->additional as $additional) {
if ($additional->name != 'USERPOINTS_USE_POINTS') {
continue;
}
$matches = array();
if (preg_match('#-([0-9]+)#', $additional->value, $matches)) {
$usePts = (int) $matches[1];
} else {
$usePts = substr($additional->value, 0, strpos($additional->value, ' '));
$usePts = (int) trim(str_replace('-', '', $usePts));
}
break;
}
if ($checkPoints > $usePts) {
$order->order_payment_params->userpoints->earn_points[$this->plugin_params->points_mode] += $usePts - $checkPoints;
$points = $usePts;
}
if ($usePts > 0) {
$points = $usePts;
}
if ($points !== false && $points > 0) {
$order->order_payment_params->userpoints->use_points += $points;
$order->order_payment_params->userpoints->use_mode = $this->plugin_params->points_mode;
}
break;
}
}
return true;
}
if (parent::onBeforeOrderCreate($order, $do) === true) {
return true;
}
if (!empty($order->cart->coupon->discount_code) && (preg_match('#^POINTS_[a-zA-Z0-9]{30}$#', $order->cart->coupon->discount_code) || preg_match('#^POINTS_([-a-zA-Z0-9]+)_[a-zA-Z0-9]{25}$#', $order->cart->coupon->discount_code))) {
if (@$this->payment_params->partialpayment === 0 && $order->cart->full_total->prices[0]->price_value_without_discount != $order->cart->coupon->discount_value) {
$do = false;
echo JText::_('ERROR_POINTS');
return true;
}
}
$check = $this->checkPoints($order);
$userPoints = $this->getUserPoints(null, $this->payment_params->points_mode);
$fullOrderPoints = $this->finalPriceToPoints($order, $userPoints);
if (($this->payment_params->partialpayment == 1 || $this->payment_params->allowshipping == 0) && ($check !== false && $check > 0) && $check < $fullOrderPoints && $userPoints) {
$discountClass = hikashop_get('class.discount');
$cartClass = hikashop_get('class.cart');
$config =& hikashop_config();
$currency = hikashop_getCurrency();
$app = JFactory::getApplication();
$newCoupon = new stdClass();
$newCoupon->discount_type = 'coupon';
$newCoupon->discount_currency_id = $currency;
$newCoupon->discount_flat_amount = $check * $this->payment_params->value;
$newCoupon->discount_quota = 1;
jimport('joomla.user.helper');
if (!empty($this->payment_params->givebackpoints)) {
$newCoupon->discount_code = 'POINTS_' . $this->payment_params->points_mode . '_';
$newCoupon->discount_code .= JUserHelper::genRandomPassword(25);
} else {
$newCoupon->discount_code = 'POINTS_';
$newCoupon->discount_code .= JUserHelper::genRandomPassword(30);
}
$newCoupon->discount_published = 1;
$discountClass->save($newCoupon);
//.........这里部分代码省略.........