PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.1
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.1
3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 2.8.17 2.8.18 All 259 releases
wpfunnels / classes / class-wpfnl-meta.php

class-wpfnl-meta.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.1, at classes/class-wpfnl-meta.php

184 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Responsible for set default order bump data
4 *
5 * @package
6 */
7 namespace WPFunnels\Meta;
8
9 class Wpfnl_Default_Meta {
10
11
12 /**
13 * Get checkout meta field
14 *
15 * @param int $post_id
16 * @param string $key
17 * @param bool $default
18 *
19 * @return mixed|void
20 * @since 2.0.3
21 */
22 public function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) {
23 $value = $this->get_meta( $post_id, $key );
24 if ( ! $value ) {
25 if (false !== $default) {
26 $value = $default;
27 }
28 }
29 return apply_filters( "wpfunnels/checkout_meta_{$key}", $value );
30 }
31
32
33 /**
34 * Get post meta value
35 *
36 * @param $post_id
37 * @param $key
38 *
39 * @return mixed
40 *
41 * @since 2.0.3
42 */
43 public function get_meta( $post_id, $key ) {
44 return get_post_meta( $post_id, $key, true );
45 }
46
47
48 /**
49 * Update funnel meta
50 *
51 * @param $post_id
52 * @param $key
53 * @param $value
54 *
55 * @since 2.0.3
56 */
57 public function update_meta( $post_id, $key, $value ) {
58 update_post_meta( $post_id, $key, $value );
59 }
60
61
62 /**
63 * Get funnel meta value by key
64 *
65 * @param $funnel_id
66 * @param $key
67 * @param $default
68 *
69 * @return mixed
70 *
71 * @since 2.0.3
72 */
73 public function get_funnel_meta( $funnel_id, $key, $default = '' ) {
74 $value = $this->get_meta( $funnel_id, $key );
75 if( $value ) {
76 return $value;
77 }
78 return $default;
79 }
80
81
82 /**
83 * Get default order bump settings
84 *
85 * @return mixed|void
86 * @since 2.0.4
87 */
88 public static function get_default_order_bump_meta() {
89 return apply_filters('wpfunnels/get_default_order_bump_data', array(
90 [
91 'selectedStyle' => '',
92 'position' => '',
93 'product' => '',
94 'quantity' => '',
95 'price' => '',
96 'salePrice' => '',
97 'htmlPrice' => '',
98 'productImage' => array(
99 'url' => '',
100 'id' => '',
101 ),
102 'highLightText' => '',
103 'checkBoxLabel' => '',
104 'productDescriptionText' => '',
105 'discountOption' => '',
106 'discountapply' => '',
107 'discountValue' => '',
108 'couponName' => '',
109 'obNextStep' => '',
110 'productName' => '',
111 'isEnabled' => 'yes',
112 'isReplace' => '',
113 'replace' => '',
114 'obPrimaryColor' => '',
115 ]
116 ));
117 }
118
119
120 /**
121 * Get default offer data
122 *
123 * @return array
124 */
125 public static function get_default_offer_product() {
126 return array(
127 'step_id' => '',
128 'id' => '',
129 'name' => '',
130 'desc' => '',
131 'qty' => '',
132 'original_price' => '',
133 'unit_price' => '',
134 'unit_price_tax' => '',
135 'args' => array(
136 'subtotal' => '',
137 'total' => '',
138 ),
139 'shipping_fee' => '',
140 'shipping_fee_incl_tax' => '',
141 'shipping_method_name' => '',
142 'price' => '',
143 'url' => '',
144 'total_unit_price_amount' => '',
145 'total' => '',
146 'cancel_main_order' => '',
147 'amount_diff' => '',
148 );
149 }
150
151
152 /**
153 * Get main product ids of a
154 * funnel
155 *
156 * @param $funnel_id
157 * @param $step_id
158 *
159 * @return mixed|void
160 */
161 public function get_main_product_ids( $funnel_id, $step_id ) {
162 $main_products = $this->get_main_products( $funnel_id, $step_id );
163 $main_product_ids = array();
164 if( $main_products && is_array($main_products) ) {
165 foreach ($main_products as $product) {
166 $main_product_ids[] = $product['id'];
167 }
168 }
169 return apply_filters( 'wpfunnels/main_product_ids', $main_product_ids, $funnel_id, $step_id );
170 }
171
172
173 /**
174 * Get main product of a funnel
175 *
176 * @param $funnel_id
177 * @param $step_id
178 *
179 * @return mixed|void
180 */
181 public function get_main_products( $funnel_id, $step_id ) {
182 return apply_filters('wpfunnels/funnel_products', $this->get_checkout_meta_value( $step_id, '_wpfnl_checkout_products' ), $funnel_id, $step_id);
183 }
184 }