Server IP : 66.29.132.122 / Your IP : 3.145.12.5 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/root/var/softaculous/sitepad/editor/site-data/plugins/kkart-pro/packages/kkart-blocks/src/StoreApi/Schemas/ |
Upload File : |
<?php namespace Automattic\Kkart\Blocks\StoreApi\Schemas; /** * OrderCouponSchema class. * * @internal This API is used internally by Blocks--it is still in flux and may be subject to revisions. */ class OrderCouponSchema extends AbstractSchema { /** * The schema item name. * * @var string */ protected $title = 'order_coupon'; /** * Cart schema properties. * * @return array */ public function get_properties() { return [ 'code' => [ 'description' => __( 'The coupons unique code.', 'kkart' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'totals' => [ 'description' => __( 'Total amounts provided using the smallest unit of the currency.', 'kkart' ), 'type' => 'object', 'context' => [ 'view', 'edit' ], 'readonly' => true, 'properties' => array_merge( $this->get_store_currency_properties(), [ 'total_discount' => [ 'description' => __( 'Total discount applied by this coupon.', 'kkart' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], 'total_discount_tax' => [ 'description' => __( 'Total tax removed due to discount applied by this coupon.', 'kkart' ), 'type' => 'string', 'context' => [ 'view', 'edit' ], 'readonly' => true, ], ] ), ], ]; } /** * Convert an order coupon to an object suitable for the response. * * @param \KKART_Order_Item_Coupon $coupon Order coupon array. * @return array */ public function get_item_response( \KKART_Order_Item_Coupon $coupon ) { return [ 'code' => $coupon->get_code(), 'totals' => (object) array_merge( $this->get_store_currency_response(), [ 'total_discount' => $this->prepare_money_response( $coupon->get_discount(), kkart_get_price_decimals() ), 'total_discount_tax' => $this->prepare_money_response( $coupon->get_discount_tax(), kkart_get_price_decimals(), PHP_ROUND_HALF_DOWN ), ] ), ]; } }