Ejemplo n.º 1
0
function _wpsc_process_transaction_coupon($purchase_log)
{
    global $wpdb;
    if (!is_object($purchase_log)) {
        $purchase_log = new WPSC_Purchase_Log($purchase_log);
    }
    $discount_data = $purchase_log->get('discount_data');
    if (!empty($discount_data)) {
        $coupon_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE coupon_code = %s LIMIT 1", $discount_data), ARRAY_A);
        $coupon = new WPSC_Coupon($coupon_data['id']);
        $coupon->used();
    }
}
 function test_is_coupon_used()
 {
     $coupon = new WPSC_Coupon(self::USE_ONCE_COUPON_ID);
     $this->assertTrue($coupon->is_active());
     $this->assertTrue($coupon->is_use_once());
     $this->assertFalse($coupon->is_used());
     $coupon->used();
     $this->assertTrue($coupon->is_used());
     $this->assertFalse($coupon->is_active());
 }