本文整理匯總了PHP中WPSC_Purchase_Log::is_order_status_completed方法的典型用法代碼示例。如果您正苦於以下問題:PHP WPSC_Purchase_Log::is_order_status_completed方法的具體用法?PHP WPSC_Purchase_Log::is_order_status_completed怎麽用?PHP WPSC_Purchase_Log::is_order_status_completed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WPSC_Purchase_Log
的用法示例。
在下文中一共展示了WPSC_Purchase_Log::is_order_status_completed方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _wpsc_action_update_product_stats
/**
* Update product stats when a purchase log containing it changes status
*
* @since 3.8.13
*
* @param int $log_id Purchase Log ID
* @param int $new_status New status
* @param int $old_status Old status
* @param WPSC_Purchase_Log $log Purchase Log
*/
function _wpsc_action_update_product_stats($log_id, $new_status, $old_status, $log)
{
$cart_contents = $log->get_cart_contents();
$new_status_completed = $log->is_transaction_completed();
$old_status_completed = WPSC_Purchase_Log::is_order_status_completed($old_status);
if ($new_status_completed && !$old_status_completed) {
// if the order went through without any trouble, then it's a positive thing!
$yay_or_boo = 1;
} elseif (!$new_status_completed && $old_status_completed) {
// if the order is declined or invalid, sad face :(
$yay_or_boo = -1;
} else {
// Not one of the above options then we will be indifferent
$yay_or_boo = 0;
}
// this dramatic mood swing affects the stats of each products in the cart
foreach ($cart_contents as $cart_item) {
$product = new WPSC_Product($cart_item->prodid);
if ($product->exists()) {
$diff_sales = $yay_or_boo * (int) $cart_item->quantity;
$diff_earnings = $yay_or_boo * (int) $cart_item->price * (int) $cart_item->quantity;
$product->sales += $diff_sales;
$product->earnings += $diff_earnings;
// if this product has parent, make the same changes to the parent
if ($product->post->post_parent) {
$parent = WPSC_Product::get_instance($product->post->post_parent);
$parent->sales += $diff_sales;
$parent->earnings += $diff_earnings;
}
}
}
}
示例2: is_transaction_completed
public function is_transaction_completed()
{
return WPSC_Purchase_Log::is_order_status_completed($this->get('processed'));
}