PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.1.4
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.1.4
2.7.0 2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 All 43 releases
sellkit / includes / dynamic-keywords / keywords / coupon-value.php

coupon-value.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.1.4, at includes/dynamic-keywords/keywords/coupon-value.php

66 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Coupon_Value extends Tag_Base {
4
5 // phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
6 public function __construct() {
7 parent::__construct();
8 }
9
10 /**
11 * Get class id.
12 *
13 * @return string
14 */
15 public function get_id() {
16 return '_coupon_value';
17 }
18
19 /**
20 * Get class title.
21 *
22 * @return string
23 */
24 public function get_title() {
25 return esc_html__( 'Coupon Value', 'sellkit' );
26 }
27
28 /**
29 * Render true content.
30 *
31 * @return string
32 */
33 public function render_content() {
34 if ( empty( self::$order ) ) {
35 $this->get_data();
36 }
37
38 $order_data = $this->get_coupon_data( self::$order );
39
40 return $order_data;
41 }
42
43 /**
44 * Get coupon data.
45 *
46 * @since 1.1.0
47 * @param object $order object of order parameters.
48 * @return array
49 */
50 public function get_coupon_data( $order ) {
51 if ( empty( $order->get_items( 'coupon' ) ) ) {
52 return;
53 }
54
55 foreach ( $order->get_items( 'coupon' ) as $coupon_id => $coupon ) {
56 $current_coupon_obj = get_page_by_title( $coupon->get_name(), OBJECT, 'shop_coupon' );
57 $current_coupon_id = $current_coupon_obj->ID;
58 $current_coupon = new WC_Coupon( $current_coupon_id );
59
60 $order_data = $current_coupon->get_data();
61 }
62
63 return $order_data['code'];
64 }
65 }
66