PluginProbe
YayMail – WooCommerce Email Customizer / 4.3.2
YayMail – WooCommerce Email Customizer v4.3.2
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / src / Shortcodes / RefundShortcodes.php

RefundShortcodes.php in YayMail – WooCommerce Email Customizer 4.3.2, at src/Shortcodes/RefundShortcodes.php

64 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Shortcodes;
4
5 use YayMail\Utils\Helpers;
6 use YayMail\Utils\SingletonTrait;
7 use YayMail\Abstracts\BaseShortcode;
8
9 /**
10 * @since 4.0.6
11 * @method: static RefundShortcodes get_instance()
12 */
13 class RefundShortcodes extends BaseShortcode {
14 use SingletonTrait;
15
16 protected function __construct() {
17 $this->available_email_ids = [ 'customer_refunded_order', 'customer_pos_refunded_order' ];
18 parent::__construct();
19 }
20
21 public function get_shortcodes() {
22 $shortcodes = [];
23 $shortcodes[] = [
24 'name' => 'yaymail_refund_type',
25 'description' => __( 'Refund Type', 'yaymail' ),
26 'group' => 'order_details',
27 'callback' => [ $this, 'yaymail_refund_type' ],
28 ];
29 return $shortcodes;
30 }
31
32 /**
33 * Render order billing shortcode
34 *
35 * @param $args includes
36 * $render_data
37 * $element
38 * $settings
39 * $is_placeholder
40 */
41 public function yaymail_refund_type( $data ) {
42
43 $render_data = isset( $data['render_data'] ) ? $data['render_data'] : [];
44
45 if ( ! empty( $render_data['is_sample'] ) ) {
46 /**
47 * Is sample order
48 */
49 return __( '(partially) refunded', 'yaymail' );
50 }
51
52 $order = Helpers::get_order_from_shortcode_data( $render_data );
53
54 if ( empty( $order ) ) {
55 /**
56 * Not having order
57 */
58 return '';
59 }
60
61 return ! empty( $render_data['partial_refund'] ) ? __( 'partially refunded', 'woocommerce' ) : __( 'refunded', 'woocommerce' );
62 }
63 }
64