本文整理汇总了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'));
}