本文整理汇总了PHP中WC_Order::get_total_discount方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::get_total_discount方法的具体用法?PHP WC_Order::get_total_discount怎么用?PHP WC_Order::get_total_discount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order
的用法示例。
在下文中一共展示了WC_Order::get_total_discount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function meta_box()
{
global $woocommerce, $post;
$order = new WC_Order($post->ID);
$order_discount = $order->get_total_discount();
$order_tax = $order->get_total_tax();
$order_subtotal = $order->get_subtotal_to_display();
$order_total = $order->get_formatted_order_total();
get_payment_gateway_fields('paypal');
woocommerce_wp_select(array('id' => 'payment_type', 'label' => '', 'value' => 'default', 'options' => ins_get_payment_methods(), 'class' => 'chosen-select'));
woocommerce_wp_select(array('id' => 'add_coupon', 'label' => '', 'value' => 'default', 'options' => ins_get_coupons(), 'class' => 'chosen-select'));
woocommerce_wp_text_input(array('id' => 'sub_total', 'label' => __('Order Subtotal', 'instore'), 'placeholder' => 0.0, 'value' => $order_subtotal));
woocommerce_wp_text_input(array('id' => 'order_tax', 'label' => __('Order Tax', 'instore'), 'placeholder' => 0.0, 'value' => $order_tax));
woocommerce_wp_text_input(array('id' => 'applied_discount', 'label' => __('Applied Discount', 'instore'), 'placeholder' => 0.0, 'value' => $order_discount));
}
示例2: getRequestData
/**
* Bundle and format the order information
* @param WC_Order $order
* Send as much information about the order as possible to Conekta
*/
function getRequestData($order)
{
if ($order and $order != null) {
// custom fields
$custom_fields = array("total_discount" => (double) $order->get_total_discount() * 100);
// $user_id = $order->get_user_id();
// $is_paying_customer = false;
$order_coupons = $order->get_used_coupons();
// if ($user_id != 0) {
// $custom_fields = array_merge($custom_fields, array(
// "is_paying_customer" => is_paying_customer($user_id)
// ));
// }
if (count($order_coupons) > 0) {
$custom_fields = array_merge($custom_fields, array("coupon_code" => $order_coupons[0]));
}
return array("amount" => (double) $order->get_total() * 100, "token" => $_POST['conektaToken'], "shipping_method" => $order->get_shipping_method(), "shipping_carrier" => $order->get_shipping_method(), "shipping_cost" => (double) $order->get_total_shipping() * 100, "monthly_installments" => (int) $_POST['monthly_installments'], "currency" => strtolower(get_woocommerce_currency()), "description" => sprintf("Charge for %s", $order->billing_email), "card" => array_merge(array("name" => sprintf("%s %s", $order->billing_first_name, $order->billing_last_name), "address_line1" => $order->billing_address_1, "address_line2" => $order->billing_address_2, "billing_company" => $order->billing_company, "phone" => $order->billing_phone, "email" => $order->billing_email, "address_city" => $order->billing_city, "address_zip" => $order->billing_postcode, "address_state" => $order->billing_state, "address_country" => $order->billing_country, "shipping_address_line1" => $order->shipping_address_1, "shipping_address_line2" => $order->shipping_address_2, "shipping_phone" => $order->shipping_phone, "shipping_email" => $order->shipping_email, "shipping_address_city" => $order->shipping_city, "shipping_address_zip" => $order->shipping_postcode, "shipping_address_state" => $order->shipping_state, "shipping_address_country" => $order->shipping_country), $custom_fields));
}
return false;
}
示例3: get_order
/**
* @param WC_Order $order
*
* @return array
*/
public static function get_order($order)
{
$serializer = array('id' => (string) $order->id, 'articles' => self::get_articles($order->get_items()), 'currency' => get_woocommerce_currency(), 'total_amount' => Aplazame_Filters::decimals($order->get_total()), 'discount' => Aplazame_Filters::decimals($order->get_total_discount()));
return $serializer;
}
示例4: process_payment
/**
* Process the payment and return the result
*
* @access public
* @param int $order_id
* @return array
*/
public function process_payment($order_id)
{
$this->init_mijireh();
$mj_order = new Mijireh_Order();
$wc_order = new WC_Order($order_id);
// add items to order
$items = $wc_order->get_items();
foreach ($items as $item) {
$product = $wc_order->get_product_from_item($item);
if (get_option('woocommerce_prices_include_tax') == 'yes') {
$mj_order->add_item($item['name'], $wc_order->get_item_subtotal($item, true, false), $item['qty'], $product->get_sku());
} else {
$mj_order->add_item($item['name'], $wc_order->get_item_subtotal($item, false, true), $item['qty'], $product->get_sku());
}
}
// Handle fees
$items = $wc_order->get_fees();
foreach ($items as $item) {
$mj_order->add_item($item['name'], number_format($item['line_total'], 2, '.', ','), 1, '');
}
// add billing address to order
$billing = new Mijireh_Address();
$billing->first_name = $wc_order->billing_first_name;
$billing->last_name = $wc_order->billing_last_name;
$billing->street = $wc_order->billing_address_1;
$billing->apt_suite = $wc_order->billing_address_2;
$billing->city = $wc_order->billing_city;
$billing->state_province = $wc_order->billing_state;
$billing->zip_code = $wc_order->billing_postcode;
$billing->country = $wc_order->billing_country;
$billing->company = $wc_order->billing_company;
$billing->phone = $wc_order->billing_phone;
if ($billing->validate()) {
$mj_order->set_billing_address($billing);
}
// add shipping address to order
$shipping = new Mijireh_Address();
$shipping->first_name = $wc_order->shipping_first_name;
$shipping->last_name = $wc_order->shipping_last_name;
$shipping->street = $wc_order->shipping_address_1;
$shipping->apt_suite = $wc_order->shipping_address_2;
$shipping->city = $wc_order->shipping_city;
$shipping->state_province = $wc_order->shipping_state;
$shipping->zip_code = $wc_order->shipping_postcode;
$shipping->country = $wc_order->shipping_country;
$shipping->company = $wc_order->shipping_company;
if ($shipping->validate()) {
$mj_order->set_shipping_address($shipping);
}
// set order name
$mj_order->first_name = $wc_order->billing_first_name;
$mj_order->last_name = $wc_order->billing_last_name;
$mj_order->email = $wc_order->billing_email;
// set order totals
$mj_order->total = $wc_order->get_total();
$mj_order->discount = $wc_order->get_total_discount();
if (get_option('woocommerce_prices_include_tax') == 'yes') {
$mj_order->shipping = round($wc_order->get_total_shipping() + $wc_order->get_shipping_tax(), 2);
$mj_order->show_tax = false;
} else {
$mj_order->shipping = round($wc_order->get_total_shipping(), 2);
$mj_order->tax = $wc_order->get_total_tax();
}
// add meta data to identify woocommerce order
$mj_order->add_meta_data('wc_order_id', $order_id);
// Set URL for mijireh payment notificatoin - use WC API
$mj_order->return_url = str_replace('https:', 'http:', add_query_arg('wc-api', 'WC_Gateway_Mijireh', home_url('/')));
// Identify woocommerce
$mj_order->partner_id = 'woo';
try {
$mj_order->create();
$result = array('result' => 'success', 'redirect' => $mj_order->checkout_url);
return $result;
} catch (Mijireh_Exception $e) {
wc_add_notice(__('Mijireh error:', 'woocommerce') . $e->getMessage(), 'error');
}
}
示例5: array
function charge_payment($order_id)
{
global $woocommerce;
$order_items = array();
$order = new WC_Order($order_id);
MEOWallet_Config::$isProduction = $this->environment == 'production' ? TRUE : FALSE;
MEOWallet_Config::$apikey = MEOWallet_Config::$isProduction ? $this->apikey_live : $this->apikey_sandbox;
//MEOWallet_Config::$isTuned = 'yes';
$params = array('payment' => array('client' => array('name' => $order->billing_first_name . ' ' . $order->billing_last_name, 'email' => $_POST['billing_email'], 'address' => array('country' => $_POST['billing_country'], 'address' => $_POST['billing_address_1'], 'city' => $_POST['billing_city'], 'postalcode' => $_POST['billing_postcode'])), 'amount' => $order->get_total(), 'currency' => 'EUR', 'items' => $items, 'url_confirm' => get_permalink(woocommerce_get_page_id('shop')) . '?' . $post_result_array->id, 'url_cancel' => get_permalink(woocommerce_get_page_id('shop')) . '?' . $post_result_array->id));
$client_details = array();
$client_details['name'] = $_POST['billing_first_name'] . ' ' . $_POST['billing_last_name'];
$client_details['email'] = $_POST['billing_email'];
//$client_details['address'] = $client_address;
$client_address = array();
$client_address['country'] = $_POST['billing_country'];
$client_address['address'] = $_POST['billing_address_1'];
$client_address['city'] = $_POST['billing_city'];
$client_address['postalcode'] = $_POST['billing_postcode'];
//$params['payment']['client'] = $client_details;
//$params['payment']['client']['address'] = $client_address;
$items = array();
if (sizeof($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
if ($item['qty']) {
$product = $order->get_product_from_item($item);
$client_items = array();
$client_items['client']['id'] = $item['id'];
$client_item['client']['name'] = $item['name'];
$client_items['client']['description'] = $item['name'];
$client_item['client']['qt'] = $item['qty'];
$items['client'][] = $client_items;
}
}
}
if ($order->get_total_shipping() > 0) {
$items[] = array('id' => 'shippingfee', 'price' => $order->get_total_shipping(), 'quantity' => 1, 'name' => 'Shipping Fee');
}
if ($order->get_total_tax() > 0) {
$items[] = array('id' => 'taxfee', 'price' => $order->get_total_tax(), 'quantity' => 1, 'name' => 'Tax');
}
if ($order->get_order_discount() > 0) {
$items[] = array('id' => 'totaldiscount', 'price' => $order->get_total_discount() * -1, 'quantity' => 1, 'name' => 'Total Discount');
}
if (sizeof($order->get_fees()) > 0) {
$fees = $order->get_fees();
$i = 0;
foreach ($fees as $item) {
$items[] = array('id' => 'itemfee' . $i, 'price' => $item['line_total'], 'quantity' => 1, 'name' => $item['name']);
$i++;
}
}
//$params['client']['amount'] = $order->get_total();
//if (get_woocommerce_currency() != 'EUR'){
// foreach ($items as &$item){
// $item['price'] = $item['price'] * $this->to_euro_rate;
// }
// unset($item);
// $params['payment']['amount'] *= $this->to_euro_rate;
//}
//$params['payment']['items'] = $items;
//$woocommerce->cart->empty_cart();
return MEOWallet_Checkout::getRedirectionUrl($params);
}
示例6: sendCustomerInvoice
function sendCustomerInvoice($order_id)
{
PlexLog::addLog(' Info =>@sendCustomerInvoice order_id=' . $order_id);
$wooCommerceOrderObject = new WC_Order($order_id);
$user_id = $wooCommerceOrderObject->get_user_id();
$customerMailId = $wooCommerceOrderObject->billing_email;
$invoice_mail_content = '';
$invoice_mail_content .= '
<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_container">
<tbody>
<tr>
<td align="center" valign="top">
<font face="Arial" style="font-weight:bold;background-color:#8fd1c8;color:#202020;"></font>
<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_header" bgcolor="#8fd1c8">
<tbody>
<tr >
<td width="20" height="20" bgcolor="#8fd1c8"> </td>
<td bgcolor="#8fd1c8"> </td>
<td width="20" bgcolor="#8fd1c8"> </td>
</tr>
<tr >
<td width="20" bgcolor="#8fd1c8"> </td>
<td bgcolor="#8fd1c8" style="font-weight:bold;font-size:24px;color:#ffffff;" ><h2 style="margin:0;">Welcome to ' . get_option('blogname') . '! <br>Thank you for your order. We\'ll be in touch shortly with additional order and shipping information.</h2></td>
<td width="20" bgcolor="#8fd1c8"> </td>
</tr>
<tr >
<td width="20" height="20" bgcolor="#8fd1c8"> </td>
<td bgcolor="#8fd1c8"> </td>
<td width="20" bgcolor="#8fd1c8"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_body">
<tbody>
<tr>
<td valign="top">
<font style="background-color:#f9f9f9">
<table border="0" cellpadding="20" cellspacing="0" width="100%">
<tbody>
<tr>
<td valign="top">
<div>
<font face="Arial" align="left" style="font-size:18px;color:#8a8a8a">
<p>Your order #' . get_post_meta($order_id, "plexOrderId", true) . ' has been received and is now being processed. Your order details are shown below for your reference:</p>
<table cellspacing="0" cellpadding="6" border="1" style="width:100%;">
<thead>
<tr>
<th scope="col">
<font align="left">Product</font>
</th>
<th scope="col">
<font align="left">Quantity</font>
</th>
<th scope="col">
<font align="left">Price</font>
</th>
</tr>
</thead>
<tbody>';
$allItems = $wooCommerceOrderObject->get_items();
foreach ($allItems as $key => $value) {
$invoice_mail_content .= '
<tr>
<td>
<font align="left">' . $value["name"] . '<br><small></small></font>
</td>
<td>
<font align="left">' . $value["qty"] . '</font>
</td>
<td>
<font align="left">
<span class="amount">$' . $value["line_subtotal"] . '</span>
</font>
</td>
</tr>';
}
$invoice_mail_content .= '
</tbody>
<tfoot style="text-align: left;">
<tr>
<th scope="row" colspan="2">
<font align="left">Cart Subtotal:</font>
</th>
<td>
<font align="left">
<span class="amount">$' . sprintf('%0.2f', $wooCommerceOrderObject->get_subtotal()) . '</span>
</font>
</td>
</tr>';
if ($wooCommerceOrderObject->get_total_discount() > 0.0) {
$invoice_mail_content .= '<tr>
<th scope="row" colspan="2">
<font align="left">Discount:</font>
</th>
<td>
<font align="left">
//.........这里部分代码省略.........
示例7: foreach
/**
* Process the payment and return the result
**/
function process_payment($order_id)
{
global $woocommerce;
require_once "alipay_config.php";
require_once "class/alipay_service.php";
$order = new WC_Order($order_id);
if (sizeof($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
if ($item['qty']) {
$item_names[] = $item['name'] . ' x ' . $item['qty'];
}
}
}
//扩展功能参数——默认支付方式
$paymethod = "directPay";
//默认支付方式,四个值可选:bankPay(网银); cartoon(卡通); directPay(余额); CASH(网点支付)
$defaultbank = "";
//扩展功能参数——防钓鱼
//请慎重选择是否开启防钓鱼功能
//exter_invoke_ip、anti_phishing_key一旦被使用过,那么它们就会成为必填参数
//开启防钓鱼功能后,服务器、本机电脑必须支持远程XML解析,请配置好该环境。
//若要使用防钓鱼功能,请打开class文件夹中alipay_function.php文件,找到该文件最下方的query_timestamp函数,根据注释对该函数进行修改
//建议使用POST方式请求数据
$anti_phishing_key = '';
//防钓鱼时间戳
$exter_invoke_ip = '';
//获取客户端的IP地址,建议:编写获取客户端IP地址的程序
//如:
//$exter_invoke_ip = '202.1.1.1';
//$anti_phishing_key = query_timestamp($partner); //获取防钓鱼时间戳函数
//扩展功能参数——其他
$extra_common_param = '';
//自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上
$buyer_email = '';
//默认买家支付宝账号
//扩展功能参数——分润(若要使用,请按照注释要求的格式赋值)
$royalty_type = "";
//提成类型,该值为固定值:10,不需要修改
$royalty_parameters = "";
//提成信息集,与需要结合商户网站自身情况动态获取每笔交易的各分润收款账号、各分润金额、各分润说明。最多只能设置10条
//各分润金额的总和须小于等于total_fee
//提成信息集格式为:收款方Email_1^金额1^备注1|收款方Email_2^金额2^备注2
//如:
//royalty_type = "10"
//royalty_parameters = "111@126.com^0.01^分润备注一|222@126.com^0.01^分润备注二"
/////////////////////////////////////////////////
//构造要请求的参数数组,无需改动
$parameter = array("service" => "create_direct_pay_by_user", "payment_type" => "1", "partner" => $partner, "seller_email" => $seller_email, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "show_url" => get_bloginfo('wpurl'), "out_trade_no" => 'CIP' . $order_id, "subject" => implode(',', $item_names), "body" => implode(',', $item_names), "total_fee" => number_format($order->get_order_total() - $order->get_total_discount(), 2, '.', ''), "paymethod" => $paymethod, "defaultbank" => $defaultbank, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "buyer_email" => $buyer_email, "extra_common_param" => $extra_common_param, "royalty_type" => $royalty_type, "royalty_parameters" => $royalty_parameters);
//构造请求函数
$alipay = new alipay_service($parameter, $key, $sign_type);
$sHtmlText = $alipay->build_form();
$html = "<html>\r\n\t\t\t<head>\r\n\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t\t\t<title>正在前往支付宝...</title>\r\n\t\t\t</head>\r\n\t\t\t<body><div style='display:none'>{$sHtmlText}</div";
echo $html;
exit;
return array('result' => 'success', 'redirect' => $sHtmlText);
}
示例8: process_payment
/**
* Process the payment and return the result
*
* @access public
* @param int $order_id
* @return array
*/
public function process_payment($order_id)
{
$this->init_mijireh();
$mj_order = new Mijireh_Order();
$wc_order = new WC_Order($order_id);
// Avoid rounding issues altogether by sending the order as one lump
if (get_option('woocommerce_prices_include_tax') == 'yes') {
// Don't pass items - Pass 1 item for the order items overall
$item_names = array();
if (sizeof($wc_order->get_items()) > 0) {
foreach ($wc_order->get_items() as $item) {
if ($item['qty']) {
$item_names[] = $item['name'] . ' x ' . $item['qty'];
}
}
}
$mj_order->add_item(sprintf(__('Order %s', 'woocommerce'), $wc_order->get_order_number()) . " - " . implode(', ', $item_names), number_format($wc_order->get_total() - round($wc_order->get_total_shipping() + $wc_order->get_shipping_tax(), 2) + $wc_order->get_order_discount(), 2, '.', ''), 1);
if ($wc_order->get_total_shipping() + $wc_order->get_shipping_tax() > 0) {
$mj_order->shipping = number_format($wc_order->get_total_shipping() + $wc_order->get_shipping_tax(), 2, '.', '');
}
$mj_order->show_tax = false;
// No issues when prices exclude tax
} else {
// add items to order
$items = $wc_order->get_items();
foreach ($items as $item) {
$product = $wc_order->get_product_from_item($item);
$mj_order->add_item($item['name'], $wc_order->get_item_subtotal($item, false, true), $item['qty'], $product->get_sku());
}
// Handle fees
$items = $wc_order->get_fees();
foreach ($items as $item) {
$mj_order->add_item($item['name'], number_format($item['line_total'], 2, '.', ','), 1, '');
}
$mj_order->shipping = round($wc_order->get_total_shipping(), 2);
$mj_order->tax = $wc_order->get_total_tax();
}
// set order totals
$mj_order->total = $wc_order->get_total();
$mj_order->discount = $wc_order->get_total_discount();
// add billing address to order
$billing = new Mijireh_Address();
$billing->first_name = $wc_order->billing_first_name;
$billing->last_name = $wc_order->billing_last_name;
$billing->street = $wc_order->billing_address_1;
$billing->apt_suite = $wc_order->billing_address_2;
$billing->city = $wc_order->billing_city;
$billing->state_province = $wc_order->billing_state;
$billing->zip_code = $wc_order->billing_postcode;
$billing->country = $wc_order->billing_country;
$billing->company = $wc_order->billing_company;
$billing->phone = $wc_order->billing_phone;
if ($billing->validate()) {
$mj_order->set_billing_address($billing);
}
// add shipping address to order
$shipping = new Mijireh_Address();
$shipping->first_name = $wc_order->shipping_first_name;
$shipping->last_name = $wc_order->shipping_last_name;
$shipping->street = $wc_order->shipping_address_1;
$shipping->apt_suite = $wc_order->shipping_address_2;
$shipping->city = $wc_order->shipping_city;
$shipping->state_province = $wc_order->shipping_state;
$shipping->zip_code = $wc_order->shipping_postcode;
$shipping->country = $wc_order->shipping_country;
$shipping->company = $wc_order->shipping_company;
if ($shipping->validate()) {
$mj_order->set_shipping_address($shipping);
}
// set order name
$mj_order->first_name = $wc_order->billing_first_name;
$mj_order->last_name = $wc_order->billing_last_name;
$mj_order->email = $wc_order->billing_email;
// add meta data to identify woocommerce order
$mj_order->add_meta_data('wc_order_id', $order_id);
// Set URL for mijireh payment notificatoin - use WC API
$mj_order->return_url = WC()->api_request_url('WC_Gateway_Mijireh');
// Identify woocommerce
$mj_order->partner_id = 'woo';
try {
$mj_order->create();
$result = array('result' => 'success', 'redirect' => $mj_order->checkout_url);
return $result;
} catch (Mijireh_Exception $e) {
wc_add_notice(__('Mijireh error:', 'woocommerce') . $e->getMessage() . print_r($mj_order, true), 'error');
}
}
示例9: foreach
/**
* Process the payment and return the result
**/
function process_payment($order_id)
{
global $woocommerce;
require_once "classes/RequestHandler.class.php";
$order = new WC_Order($order_id);
if (sizeof($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
if ($item['qty']) {
$item_names[] = $item['name'] . ' x ' . $item['qty'];
}
}
}
//////////////////////////////
/* 商户号 */
$partner = $this->tenpayUid;
/* 密钥 */
$key = $this->tenpayKey;
//订单号,此处用时间加随机数生成,商户根据自己情况调整,只要保持全局唯一就行
$out_trade_no = 'CIP' . $order_id;
/* 创建支付请求对象 */
$reqHandler = new RequestHandler();
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setGateUrl("https://gw.tenpay.com/gateway/pay.htm");
//----------------------------------------
//设置支付参数
//----------------------------------------
$reqHandler->setParameter("partner", $partner);
$reqHandler->setParameter("out_trade_no", $out_trade_no);
$reqHandler->setParameter("total_fee", ($order->get_order_total() - $order->get_total_discount()) * 100);
//总金额
$reqHandler->setParameter("return_url", CI_WC_ALI_PATH . "/payReturnUrl.php");
$reqHandler->setParameter("notify_url", CI_WC_ALI_PATH . "/payNotifyUrl.php");
$reqHandler->setParameter("body", implode(',', $item_names));
$reqHandler->setParameter("bank_type", "DEFAULT");
//银行类型,默认为财付通
//用户ip
$reqHandler->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);
//客户端IP
$reqHandler->setParameter("fee_type", "1");
//币种
$reqHandler->setParameter("subject", '');
//商品名称,(中介交易时必填)
//系统可选参数
$reqHandler->setParameter("sign_type", "MD5");
//签名方式,默认为MD5,可选RSA
$reqHandler->setParameter("service_version", "1.0");
//接口版本号
$reqHandler->setParameter("input_charset", "UTF-8");
//字符集
$reqHandler->setParameter("sign_key_index", "1");
//密钥序号
//业务可选参数
$reqHandler->setParameter("attach", "");
//附件数据,原样返回就可以了
$reqHandler->setParameter("product_fee", "");
//商品费用
$reqHandler->setParameter("transport_fee", "0");
//物流费用
$reqHandler->setParameter("time_start", date("YmdHis"));
//订单生成时间
$reqHandler->setParameter("time_expire", "");
//订单失效时间
$reqHandler->setParameter("buyer_id", "");
//买方财付通帐号
$reqHandler->setParameter("goods_tag", "");
//商品标记
$reqHandler->setParameter("trade_mode", "1");
//交易模式(1.即时到帐模式,2.中介担保模式,3.后台选择(卖家进入支付中心列表选择))
$reqHandler->setParameter("transport_desc", "");
//物流说明
$reqHandler->setParameter("trans_type", "1");
//交易类型
$reqHandler->setParameter("agentid", "");
//平台ID
$reqHandler->setParameter("agent_type", "");
//代理模式(0.无代理,1.表示卡易售模式,2.表示网店模式)
$reqHandler->setParameter("seller_id", "");
//卖家的商户号
$reqUrl = $reqHandler->getRequestURL();
$html_text = '
<script>window.location.href="' . $reqUrl . '"</script>';
//param end
$output = "\r\n\t\t\t<html>\r\n\t\t <head>\r\n\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t <title>正在前往财付通...</title>\r\n\t\t </head>\r\n\t\t <body>{$html_text}</body></html>";
echo $output;
exit;
return array('result' => 'success', 'redirect' => $output);
}
示例10: foreach
/**
* Process the payment and return the result
**/
function process_payment($order_id)
{
global $woocommerce;
$order = new WC_Order($order_id);
if (sizeof($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
if ($item['qty']) {
$item_names[] = $item['name'] . ' x ' . $item['qty'];
}
}
}
//
$v_mid = $this->bankUid;
// 商户号,这里为测试商户号1001,替换为自己的商户号(老版商户号为4位或5位,新版为8位)即可
$v_url = CI_WC_ALI_PATH . '/chinabank/receive.php';
// 请填写返回url,地址应为绝对路径,带有http协议
$key = $this->bankKey;
$v_oid = 'CIP' . $order_id;
$v_amount = number_format($order->get_order_total() - $order->get_total_discount(), 2, '.', '');
//支付金额
$v_moneytype = "CNY";
//币种
$text = $v_amount . $v_moneytype . $v_oid . $v_mid . $v_url . $key;
//md5加密拼凑串,注意顺序不能变
$v_md5info = strtoupper(md5($text));
//md5函数加密并转化成大写字母
$remark1 = '';
//备注字段1
$remark2 = '';
//备注字段2
$v_rcvname = '';
// 收货人
$v_rcvaddr = '';
// 收货地址
$v_rcvtel = '';
// 收货人电话
$v_rcvpost = '';
// 收货人邮编
$v_rcvemail = '';
// 收货人邮件
$v_rcvmobile = '';
// 收货人手机号
$v_ordername = '';
// 订货人姓名
$v_orderaddr = '';
// 订货人地址
$v_ordertel = '';
// 订货人电话
$v_orderpost = '';
// 订货人邮编
$v_orderemail = '';
// 订货人邮件
$v_ordermobile = '';
// 订货人手机号
$html_text = '
<form method="post" name="E_FORM" action="https://pay3.chinabank.com.cn/PayGate">
<input type="hidden" name="v_mid" value="' . $v_mid . '">
<input type="hidden" name="v_oid" value="' . $v_oid . '">
<input type="hidden" name="v_amount" value="' . $v_amount . '">
<input type="hidden" name="v_moneytype" value="' . $v_moneytype . '">
<input type="hidden" name="v_url" value="' . $v_url . '">
<input type="hidden" name="v_md5info" value="' . $v_md5info . '">
<input type="hidden" name="remark1" value="' . $remark1 . '">
<input type="hidden" name="remark2" value="' . $remark2 . '">
</form>
<script>document.E_FORM.submit();</script>';
$output = "\r\n\t\t\t<html>\r\n\t\t <head>\r\n\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t <title>正在前往网银在线...</title>\r\n\t\t </head>\r\n\t\t <body><div style='display:none'>{$html_text}</div>'</body></html>";
echo $output;
exit;
return array('result' => 'success', 'redirect' => $output);
}
示例11: add_payment_details_parameters
/**
* Set up the payment details for a DoExpressCheckoutPayment or DoReferenceTransaction request
*
* @since 2.0.9
* @param WC_Order $order order object
* @param string $type the type of transaction for the payment
* @param bool $use_deprecated_params whether to use deprecated PayPal NVP parameters (required for DoReferenceTransaction API calls)
*/
protected function add_payment_details_parameters(WC_Order $order, $type, $use_deprecated_params = false)
{
$calculated_total = 0;
$order_subtotal = 0;
$item_count = 0;
$order_items = array();
// add line items
foreach ($order->get_items() as $item) {
$product = new WC_Product($item['product_id']);
$order_items[] = array('NAME' => wcs_get_paypal_item_name($product->get_title()), 'DESC' => $this->get_item_description($item, $product), 'AMT' => $this->round($order->get_item_subtotal($item)), 'QTY' => !empty($item['qty']) ? absint($item['qty']) : 1, 'ITEMURL' => $product->get_permalink());
$order_subtotal += $item['line_total'];
}
// add fees
foreach ($order->get_fees() as $fee) {
$order_items[] = array('NAME' => wcs_get_paypal_item_name($fee['name']), 'AMT' => $this->round($fee['line_total']), 'QTY' => 1);
$order_subtotal += $fee['line_total'];
}
// add discounts
if ($order->get_total_discount() > 0) {
$order_items[] = array('NAME' => __('Total Discount', 'woocommerce-subscriptions'), 'QTY' => 1, 'AMT' => -$this->round($order->get_total_discount()));
}
if ($this->skip_line_items($order)) {
$total_amount = $this->round($order->get_total());
// calculate the total as PayPal would
$calculated_total += $this->round($order_subtotal + $order->get_cart_tax()) + $this->round($order->get_total_shipping() + $order->get_shipping_tax());
// offset the discrepency between the WooCommerce cart total and PayPal's calculated total by adjusting the order subtotal
if ($total_amount !== $calculated_total) {
$order_subtotal = $order_subtotal - ($calculated_total - $total_amount);
}
$item_names = array();
foreach ($order_items as $item) {
$item_names[] = sprintf('%1$s x %2$s', $item['NAME'], $item['QTY']);
}
// add a single item for the entire order
$this->add_line_item_parameters(array('NAME' => sprintf(__('%s - Order', 'woocommerce-subscriptions'), get_option('blogname')), 'DESC' => wcs_get_paypal_item_name(implode(', ', $item_names)), 'AMT' => $this->round($order_subtotal + $order->get_cart_tax()), 'QTY' => 1), 0, $use_deprecated_params);
// add order-level parameters
// - Do not sent the TAXAMT due to rounding errors
if ($use_deprecated_params) {
$this->add_parameters(array('AMT' => $total_amount, 'CURRENCYCODE' => $order->get_order_currency(), 'ITEMAMT' => $this->round($order_subtotal + $order->get_cart_tax()), 'SHIPPINGAMT' => $this->round($order->get_total_shipping() + $order->get_shipping_tax()), 'INVNUM' => WCS_PayPal::get_option('invoice_prefix') . wcs_str_to_ascii(ltrim($order->get_order_number(), _x('#', 'hash before the order number. Used as a character to remove from the actual order number', 'woocommerce-subscriptions'))), 'PAYMENTACTION' => $type, 'PAYMENTREQUESTID' => $order->id, 'CUSTOM' => json_encode(array('order_id' => $order->id, 'order_key' => $order->order_key))));
} else {
$this->add_payment_parameters(array('AMT' => $total_amount, 'CURRENCYCODE' => $order->get_order_currency(), 'ITEMAMT' => $this->round($order_subtotal + $order->get_cart_tax()), 'SHIPPINGAMT' => $this->round($order->get_total_shipping() + $order->get_shipping_tax()), 'INVNUM' => WCS_PayPal::get_option('invoice_prefix') . wcs_str_to_ascii(ltrim($order->get_order_number(), _x('#', 'hash before the order number. Used as a character to remove from the actual order number', 'woocommerce-subscriptions'))), 'PAYMENTACTION' => $type, 'PAYMENTREQUESTID' => $order->id, 'CUSTOM' => json_encode(array('order_id' => $order->id, 'order_key' => $order->order_key))));
}
} else {
// add individual order items
foreach ($order_items as $item) {
$this->add_line_item_parameters($item, $item_count++, $use_deprecated_params);
$calculated_total += $this->round($item['AMT'] * $item['QTY']);
}
// add shipping and tax to calculated total
$calculated_total += $this->round($order->get_total_shipping()) + $this->round($order->get_total_tax());
$total_amount = $this->round($order->get_total());
// add order-level parameters
if ($use_deprecated_params) {
$this->add_parameters(array('AMT' => $total_amount, 'CURRENCYCODE' => $order->get_order_currency(), 'ITEMAMT' => $this->round($order_subtotal), 'SHIPPINGAMT' => $this->round($order->get_total_shipping()), 'TAXAMT' => $this->round($order->get_total_tax()), 'INVNUM' => WCS_PayPal::get_option('invoice_prefix') . wcs_str_to_ascii(ltrim($order->get_order_number(), _x('#', 'hash before the order number. Used as a character to remove from the actual order number', 'woocommerce-subscriptions'))), 'PAYMENTACTION' => $type, 'PAYMENTREQUESTID' => $order->id, 'CUSTOM' => json_encode(array('order_id' => $order->id, 'order_key' => $order->order_key))));
} else {
$this->add_payment_parameters(array('AMT' => $total_amount, 'CURRENCYCODE' => $order->get_order_currency(), 'ITEMAMT' => $this->round($order_subtotal), 'SHIPPINGAMT' => $this->round($order->get_total_shipping()), 'TAXAMT' => $this->round($order->get_total_tax()), 'INVNUM' => WCS_PayPal::get_option('invoice_prefix') . wcs_str_to_ascii(ltrim($order->get_order_number(), _x('#', 'hash before the order number. Used as a character to remove from the actual order number', 'woocommerce-subscriptions'))), 'PAYMENTACTION' => $type, 'PAYMENTREQUESTID' => $order->id, 'CUSTOM' => json_encode(array('order_id' => $order->id, 'order_key' => $order->order_key))));
}
// offset the discrepency between the WooCommerce cart total and PayPal's calculated total by adjusting the cost of the first item
if ($total_amount !== $calculated_total) {
$this->parameters['L_PAYMENTREQUEST_0_AMT0'] = $this->parameters['L_PAYMENTREQUEST_0_AMT0'] - ($calculated_total - $total_amount);
}
}
}
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:71,代码来源:class-wcs-paypal-reference-transaction-api-request.php
示例12: ConfirmPayment
//.........这里部分代码省略.........
*/
foreach (WC()->cart->get_fees() as $fee) {
$Item = array('name' => $fee->name, 'desc' => '', 'amt' => number_format($fee->amount, 2, '.', ''), 'number' => $fee->id, 'qty' => 1, 'taxamt' => '', 'itemurl' => '', 'itemcategory' => '', 'itemweightvalue' => '', 'itemweightunit' => '', 'itemheightvalue' => '', 'itemheightunit' => '', 'itemwidthvalue' => '', 'itemwidthunit' => '', 'itemlengthvalue' => '', 'itemlengthunit' => '', 'ebayitemnumber' => '', 'ebayitemauctiontxnid' => '', 'ebayitemorderid' => '', 'ebayitemcartid' => '');
/**
* The gift wrap amount actually has its own parameter in
* DECP, so we don't want to include it as one of the line
* items.
*/
if ($Item['number'] != 'gift-wrap') {
array_push($PaymentOrderItems, $Item);
$ITEMAMT += $fee->amount * $Item['qty'];
}
$ctr++;
}
if (!$this->is_wc_version_greater_2_3()) {
/*
* Get discounts
*/
if ($order->get_cart_discount() > 0) {
foreach (WC()->cart->get_coupons('cart') as $code => $coupon) {
$Item = array('name' => 'Cart Discount', 'number' => $code, 'qty' => '1', 'amt' => '-' . number_format(WC()->cart->coupon_discount_amounts[$code], 2, '.', ''));
array_push($PaymentOrderItems, $Item);
}
$total_discount -= $order->get_cart_discount();
}
if ($order->get_order_discount() > 0) {
foreach (WC()->cart->get_coupons('order') as $code => $coupon) {
$Item = array('name' => 'Order Discount', 'number' => $code, 'qty' => '1', 'amt' => '-' . number_format(WC()->cart->coupon_discount_amounts[$code], 2, '.', ''));
array_push($PaymentOrderItems, $Item);
}
$total_discount -= $order->get_order_discount();
}
} else {
if ($order->get_total_discount() > 0) {
$Item = array('name' => 'Total Discount', 'qty' => 1, 'amt' => -number_format($order->get_total_discount(), 2, '.', ''));
array_push($PaymentOrderItems, $Item);
$total_discount -= $order->get_total_discount();
}
}
}
/*
* Set shipping and tax values.
*/
if (get_option('woocommerce_prices_include_tax') == 'yes') {
$shipping = $order->get_total_shipping() + $order->get_shipping_tax();
$tax = 0;
} else {
$shipping = $order->get_total_shipping();
$tax = $order->get_total_tax();
}
if ('yes' === get_option('woocommerce_calc_taxes') && 'yes' === get_option('woocommerce_prices_include_tax')) {
$tax = $order->get_total_tax();
}
if ($tax > 0) {
$tax = number_format($tax, 2, '.', '');
}
if ($shipping > 0) {
$shipping = number_format($shipping, 2, '.', '');
}
if ($total_discount) {
$total_discount = round($total_discount, 2);
}
if ($this->send_items) {
/*
* Now that we have all items and subtotals
* we can fill in necessary values.
示例13: do_reference_transaction
/**
* Charge a payment against a reference token
*
* @link https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECReferenceTxns/#id094UM0DA0HS
* @link https://developer.paypal.com/docs/classic/api/merchant/DoReferenceTransaction_API_Operation_NVP/
*
* @param string $reference_id the ID of a refrence object, e.g. billing agreement ID.
* @param WC_Order $order order object
* @param array $args {
* @type string 'payment_type' (Optional) Specifies type of PayPal payment you require for the billing agreement. It is one of the following values. 'Any' or 'InstantOnly'. Echeck is not supported for DoReferenceTransaction requests.
* @type string 'payment_action' How you want to obtain payment. It is one of the following values: 'Authorization' - this payment is a basic authorization subject to settlement with PayPal Authorization and Capture; or 'Sale' - This is a final sale for which you are requesting payment.
* @type string 'return_fraud_filters' (Optional) Flag to indicate whether you want the results returned by Fraud Management Filters. By default, you do not receive this information.
* }
* @since 2.0
*/
public function do_reference_transaction($reference_id, $order, $args = array())
{
$defaults = array('amount' => $order->get_total(), 'payment_type' => 'Any', 'payment_action' => 'Sale', 'return_fraud_filters' => 1, 'notify_url' => WC()->api_request_url('WC_Gateway_Paypal'), 'invoice_number' => wcs_str_to_ascii(ltrim($order->get_order_number(), _x('#', 'hash before the order number', 'woocommerce-subscriptions'))), 'custom' => json_encode(array('order_id' => $order->id, 'order_key' => $order->order_key)));
$args = wp_parse_args($args, $defaults);
$this->set_method('DoReferenceTransaction');
// set base params
$this->add_parameters(array('REFERENCEID' => $reference_id, 'BUTTONSOURCE' => 'WooThemes_Cart', 'RETURNFMFDETAILS' => $args['return_fraud_filters'], 'AMT' => $order->get_total(), 'CURRENCYCODE' => $order->get_order_currency(), 'INVNUM' => $args['invoice_number'], 'PAYMENTACTION' => $args['payment_action'], 'NOTIFYURL' => $args['notify_url'], 'CUSTOM' => $args['custom']));
$order_subtotal = $i = 0;
$order_items = array();
// add line items
foreach ($order->get_items() as $item) {
$order_items[] = array('NAME' => wcs_get_paypal_item_name($item['name']), 'AMT' => $order->get_item_subtotal($item), 'QTY' => !empty($item['qty']) ? absint($item['qty']) : 1);
$order_subtotal += $item['line_total'];
}
// add fees
foreach ($order->get_fees() as $fee) {
$order_items[] = array('NAME' => wcs_get_paypal_item_name($fee['name']), 'AMT' => $fee['line_total'], 'QTY' => 1);
$order_subtotal += $fee['line_total'];
}
// WC 2.3+, no after-tax discounts
if ($order->get_total_discount() > 0) {
$order_items[] = array('NAME' => __('Total Discount', 'woocommerce-subscriptions'), 'QTY' => 1, 'AMT' => -$order->get_total_discount());
}
if ($order->prices_include_tax) {
$item_names = array();
foreach ($order_items as $item) {
$item_names[] = sprintf('%s x %s', $item['NAME'], $item['QTY']);
}
// add a single item for the entire order
$this->add_line_item_parameters(array('NAME' => sprintf(__('%s - Order', 'woocommerce-subscriptions'), get_option('blogname')), 'DESC' => wcs_get_paypal_item_name(implode(', ', $item_names)), 'AMT' => $order_subtotal + $order->get_cart_tax(), 'QTY' => 1), 0);
// add order-level parameters - do not send the TAXAMT due to rounding errors
$this->add_payment_parameters(array('ITEMAMT' => $order_subtotal + $order->get_cart_tax(), 'SHIPPINGAMT' => $order->get_total_shipping() + $order->get_shipping_tax()));
} else {
// add individual order items
foreach ($order_items as $item) {
$this->add_line_item_parameters($item, $i++);
}
// add order-level parameters
$this->add_payment_parameters(array('ITEMAMT' => $order_subtotal, 'SHIPPINGAMT' => $order->get_total_shipping(), 'TAXAMT' => $order->get_total_tax()));
}
}
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:56,代码来源:class-wcs-paypal-reference-transaction-api-request.php
示例14: successful_request
/**
* After the payment method and validation data from transparent-checkout.php this method is called
* to send the real payment information to gerencianet
*
* Also this method handle with notifications of any status of the payment
*
* @param array $posted gerencianet post data.
*
* @return void
*/
public function successful_request($posted)
{
//If the IPN request is about notification
if (!empty($posted['notificacao'])) {
try {
include_once 'gerencianet-api/ApiCheckoutGerencianet.php';
$url = 'https://go.gerencianet.com.br/api/notificacao/xml';
$apiGerenciaNet = new ApiCheckoutGerencianet($url);
$token = $this->token;
$notification_code = $posted['notificacao'];
$parametros = array($notification_code => 'notificacao');
$result = $apiGerenciaNet->consultarStatusPagamento($parametros, $token);
$result = simplexml_load_string($result);
$order = new WC_Order($result->resposta->identificador);
if (!empty($order)) {
$status = $result->resposta->status;
switch ($status) {
case 'aguardando':
$order->update_status('pending', __('Waiting Payment nº ') . $result->resposta->transacao);
break;
case 'pago':
$order->update_status('completed', __('All payment process completed transaction nº ') . $result->resposta->transacao);
break;
case 'cancelado':
$order->update_status('cancelled', __('Order cancelled transaction nº ') . $result->resposta->transacao);
break;
case 'vencido':
$order->update_status('failed', __('Order failed transaction nº ') . $result->resposta->transacao);
break;
default:
//no action
break;
}
if ('yes' == $this->debug) {
$this->log->add('gerencianet', 'changing status order ' . $order->get_order_number());
}
} else {
if ('yes' == $this->debug) {
$this->log->add('gerencianet', 'changing status order error ' . $e->getMessage());
}
}
} catch (Exception $e) {
if ('yes' == $this->debug) {
$this->log->add('gerencianet', 'changing status order error ' . $e->getMessage());
}
}
exit;
}
//if the IPN request is about payment
if (!empty($posted['tokenPagamento'])) {
try {
include_once 'gerencianet-api/ApiCheckoutGerencianet.php';
$order = new WC_Order($posted['outros']['wc_order_id']);
// Payment URL or Sandbox URL.
$payment_url = 'https://go.gerencianet.com.br/api/checkout/pagar/xml';
if ('yes' == $this->sandbox) {
$payment_url = 'https://go.gerencianet.com.br/teste/api/checkout/pagar/xml';
}
$apiGerenciaNet = new ApiCheckoutGerencianet($payment_url);
$token = $this->token;
$tokenPagamento = $posted['tokenPagamento'];
$order_items = $order->get_items();
$items = array();
foreach ($order_items as $items_key => $item) {
$items[] = array("itemDescricao" => $item['name'], "itemValor" => $this->price_cents_format($item['line_total'] / $item['qty']), "itemQuantidade" => $item['qty']);
}
$retorno = array('identificador' => $posted['outros']['wc_order_id'], 'urlNotificacao' => home_url('/?wc-api=WC_Gerencianet'));
$client = $posted['cliente'];
$enderecoEntrega = $posted['enderecoEntrega'];
//forma de entrega
$formaEntrega = array();
if ($posted['metodo'] == 'boleto') {
$date = $order->order_date;
$date = date_create($date);
date_add($date, date_interval_create_from_date_string($this->billet_number_days . ' days'));
$formaEntrega['boleto'] = array('vencimento' => date_format($date, 'Y-m-d'));
} else {
if ($posted['metodo'] == 'cartao-credito') {
$parcelas = $posted['formaPagamento']['cartao']['parcelas'];
$formaEntrega['cartao'] = array('parcelas' => $parcelas, 'enderecoCobranca' => $enderecoEntrega);
}
}
$parametros = array('itens' => $items, 'retorno' => $retorno, 'desconto' => $this->price_cents_format($order->get_total_discount()), 'frete' => $this->price_cents_format($order->get_total_shipping()), 'tipo' => 'produto', 'cliente' => $client, 'enderecoEntrega' => $enderecoEntrega, 'formaPagamento' => $formaEntrega);
$result = $apiGerenciaNet->pagar($parametros, $token, $tokenPagamento);
$result = simplexml_load_string($result);
$result->redirect = $posted['outros']['wc_redirect'];
$result->tokenPagamento = $tokenPagamento;
echo json_encode($result);
if ('yes' == $this->debug) {
$this->log->add('gerencianet', 'Sending payment ' . print_r($parametros, true) . ' token =>' . $token . ' tokenPagamento => ' . $tokenPagamento);
//.........这里部分代码省略.........
示例15: bp_course_enable_access
function bp_course_enable_access($order_id)
{
$order = new WC_Order($order_id);
$items = $order->get_items();
$user_id = $order->user_id;
$order_total = $order->get_total();
$total_discount = $order->get_total_discount();
$commission_array = array();
foreach ($items as $item_id => $item) {
$instructors = array();
$product_id = $item['product_id'];
$subscribed = get_post_meta($product_id, 'vibe_subscription', true);
$courses = vibe_sanitize(get_post_meta($product_id, 'vibe_courses', false));
if ($total_discount) {
$multiplier = round($order_total / ($order_total + $total_discount), 4);
}
if (isset($courses) && is_array($courses)) {
if (vibe_validate($subscribed)) {
$duration = get_post_meta($product_id, 'vibe_duration', true);
$product_duration_parameter = apply_filters('vibe_product_duration_parameter', 86400);
// Product duration for subscription based
foreach ($courses as $course) {
$start_date = get_post_meta($course, 'vibe_start_date', true);
$time = 0;
if (isset($start_date) && $start_date) {
$time = strtotime($start_date);
}
if ($time < time()) {
$time = time();
}
$t = $time + $duration * $product_duration_parameter;
update_post_meta($course, $user_id, 0);
update_user_meta($user_id, $course, $t);
update_user_meta($user_id, 'course_status' . $course, 1);
$group_id = get_post_meta($course, 'vibe_group', true);
if (isset($group_id) && $group_id != '' && is_numeric($group_id) && function_exists('groups_join_group')) {
groups_join_group($group_id, $user_id);
} else {
$group_id = '';
}
$durationtime = $duration . ' ' . calculate_duration_time($product_duration_parameter);
if ($duration == '9999') {
$durationtime = __('Unlimited Duration', 'vibe');
}
do_action('wplms_course_subscribed', $course, $user_id, $group_id);
$instructors[$course] = apply_filters('wplms_course_instructors', get_post_field('post_author', $course), $course);
do_action('wplms_course_product_puchased', $course, $user_id, $t, 1);
}
} else {
if (isset($courses) && is_array($courses)) {
foreach ($courses as $course) {
$duration = get_post_meta($course, 'vibe_duration', true);
$course_duration_parameter = apply_filters('vibe_course_duration_parameter', 86400);
// Course duration for subscription based
$start_date = get_post_meta($course, 'vibe_start_date', true);
$time = 0;
if (isset($start_date) && $start_date) {
$time = strtotime($start_date);
}
if ($time < time()) {
$time = time();
}
$t = $time + $duration * $course_duration_parameter;
update_post_meta($course, $user_id, 0);
update_user_meta($user_id, $course, $t);
update_user_meta($user_id, 'course_status' . $course, 1);
$group_id = get_post_meta($course, 'vibe_group', true);
if (isset($group_id) && $group_id != '' && is_numeric($group_id) && function_exists('groups_join_group')) {
groups_join_group($group_id, $user_id);
} else {
$group_id = '';
}
$durationtime = $duration . ' ' . calculate_duration_time($product_duration_parameter);
if ($duration == '9999') {
$durationtime = __('Unlimited Duration', 'vibe');
}
do_action('wplms_course_subscribed', $course, $user_id, $group_id);
$instructors[$course] = apply_filters('wplms_course_instructors', get_post_field('post_author', $course, 'raw'), $course);
do_action('wplms_course_product_puchased', $course, $user_id, $t, 0);
}
}
}
//End Else
if ($total_discount) {
// Product discounted
$line_total = round($item['line_total'] * $multiplier, 2);
} else {
$line_total = $item['line_total'];
}
//Commission Calculation
$commission_array[$item_id] = array('instructor' => $instructors, 'course' => $courses, 'total' => $line_total);
}
//End If courses
}
// End Item for loop
if (function_exists('vibe_get_option')) {
$instructor_commission = vibe_get_option('instructor_commission');
}
if ($instructor_commission == 0) {
return;
//.........这里部分代码省略.........