PluginProbe
Cashfree for WooCommerce / 4.8.0
Cashfree for WooCommerce v4.8.0
4.8.1 4.8.0 trunk 1.0 1.2 4.2.1 4.2.2 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.5.0 4.5.1 All 42 releases
cashfree / includes / request / class-wc-cashfree-request-items.php

class-wc-cashfree-request-items.php in Cashfree for WooCommerce 4.8.0, at includes/request/class-wc-cashfree-request-items.php

35 lines 844 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Item request
4 */
5
6 defined( 'ABSPATH' ) || exit;
7
8 /**
9 * Item request class.
10 */
11 class WC_Cashfree_Request_Item {
12
13 /**
14 * Build request.
15 *
16 * @param WC_Order $order Order instance.
17 * @param WC_Order_Item_Product $item Item in cart instance.
18 *
19 * @return array
20 */
21 public static function build( $item ) {
22 return array(
23 'item_name' => mb_convert_encoding(substr( $item->get_name(), 0, 254 ), 'UTF-8', 'UTF-8'),
24 'item_original_unit_price' => self::cfConvertToNumber($item->get_total() ? $item->get_total() : 0),
25 'item_quantity' => $item->get_quantity(),
26 );
27 }
28
29 public static function cfConvertToNumber($input) {
30 $amount = (float) str_replace(',', '', $input);
31 $amount = number_format($amount, 2, '.', '');
32 return $amount;
33 }
34 }
35