__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Automattic\WooCommerce\StoreApi\Schemas\V1;
/**
* OrderCouponSchema class.
*/
class OrderCouponSchema extends AbstractSchema {
/**
* The schema item name.
*
* @var string
*/
protected $title = 'order_coupon';
/**
* The schema item identifier.
*
* @var string
*/
const IDENTIFIER = 'order-coupon';
/**
* Cart schema properties.
*
* @return array
*/
public function get_properties() {
return [
'code' => [
'description' => __( 'The coupons unique code.', 'woocommerce' ),
'type' => 'string',
'context' => [ 'view', 'edit' ],
'readonly' => true,
],
'discount_type' => [
'description' => __( 'The discount type for the coupon (e.g. percentage or fixed amount)', 'woocommerce' ),
'type' => 'string',
'context' => [ 'view', 'edit' ],
'readonly' => true,
],
'totals' => [
'description' => __( 'Total amounts provided using the smallest unit of the currency.', 'woocommerce' ),
'type' => 'object',
'context' => [ 'view', 'edit' ],
'readonly' => true,
'properties' => array_merge(
$this->get_store_currency_properties(),
[
'total_discount' => [
'description' => __( 'Total discount applied by this coupon.', 'woocommerce' ),
'type' => 'string',
'context' => [ 'view', 'edit' ],
'readonly' => true,
],
'total_discount_tax' => [
'description' => __( 'Total tax removed due to discount applied by this coupon.', 'woocommerce' ),
'type' => 'string',
'context' => [ 'view', 'edit' ],
'readonly' => true,
],
]
),
],
];
}
/**
* Convert an order coupon to an object suitable for the response.
*
* @param \WC_Order_Item_Coupon $coupon Order coupon object.
* @return array
*/
public function get_item_response( $coupon ) {
$coupon_object = new \WC_Coupon( $coupon->get_code() );
return [
'code' => $coupon->get_code(),
'discount_type' => $coupon_object ? $coupon_object->get_discount_type() : '',
'totals' => (object) $this->prepare_currency_response(
[
'total_discount' => $this->prepare_money_response( $coupon->get_discount(), wc_get_price_decimals() ),
'total_discount_tax' => $this->prepare_money_response( $coupon->get_discount_tax(), wc_get_price_decimals(), PHP_ROUND_HALF_DOWN ),
]
),
];
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| AI | Folder | 0775 |
|
|
| Agentic | Folder | 0775 |
|
|
| AbstractAddressSchema.php | File | 10.58 KB | 0664 |
|
| AbstractSchema.php | File | 12.83 KB | 0664 |
|
| BatchSchema.php | File | 427 B | 0664 |
|
| BillingAddressSchema.php | File | 4.46 KB | 0664 |
|
| CartCouponSchema.php | File | 2.98 KB | 0664 |
|
| CartExtensionsSchema.php | File | 2.21 KB | 0664 |
|
| CartFeeSchema.php | File | 2.12 KB | 0664 |
|
| CartItemSchema.php | File | 7.55 KB | 0664 |
|
| CartSchema.php | File | 15.82 KB | 0664 |
|
| CartShippingRateSchema.php | File | 11.37 KB | 0664 |
|
| CheckoutOrderSchema.php | File | 752 B | 0664 |
|
| CheckoutSchema.php | File | 15.05 KB | 0664 |
|
| ErrorSchema.php | File | 1.12 KB | 0664 |
|
| ImageAttachmentSchema.php | File | 2.55 KB | 0664 |
|
| ItemSchema.php | File | 11.27 KB | 0664 |
|
| OrderCouponSchema.php | File | 2.41 KB | 0664 |
|
| OrderFeeSchema.php | File | 2.2 KB | 0664 |
|
| OrderItemSchema.php | File | 2.79 KB | 0664 |
|
| OrderSchema.php | File | 12.74 KB | 0664 |
|
| PatternsSchema.php | File | 673 B | 0664 |
|
| ProductAttributeSchema.php | File | 2.5 KB | 0664 |
|
| ProductBrandSchema.php | File | 3.49 KB | 0664 |
|
| ProductCategorySchema.php | File | 3.5 KB | 0664 |
|
| ProductCollectionDataSchema.php | File | 4.95 KB | 0664 |
|
| ProductReviewSchema.php | File | 6.12 KB | 0664 |
|
| ProductSchema.php | File | 32.79 KB | 0664 |
|
| ShippingAddressSchema.php | File | 2.84 KB | 0664 |
|
| TermSchema.php | File | 2.15 KB | 0664 |
|