@@ -27,18 +27,18 @@ discard block |
||
| 27 | 27 | 'subscription_initial_payment' => 'get_subscription_initial', |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
| 31 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), array( __CLASS__, $function ) ); |
|
| 30 | + foreach ($shortcodes as $shortcode => $function) { |
|
| 31 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), array(__CLASS__, $function)); |
|
| 32 | 32 | } // END foreach() |
| 33 | 33 | |
| 34 | 34 | // Adds support for product types that have subscription scheme options. |
| 35 | - add_filter( 'woocommerce_is_subscription', array( __CLASS__, 'force_is_subscription' ), 10, 3 ); |
|
| 35 | + add_filter('woocommerce_is_subscription', array(__CLASS__, 'force_is_subscription'), 10, 3); |
|
| 36 | 36 | |
| 37 | 37 | // Adds alternative subscription price from the WooCommerce extension "Subscribe to All the Things" and returns the lowest scheme price. |
| 38 | - add_action( 'woocommerce_subscriptions_shortcode_get_price', array( __CLASS__, 'get_satt_lowest_price' ), 10, 1 ); |
|
| 38 | + add_action('woocommerce_subscriptions_shortcode_get_price', array(__CLASS__, 'get_satt_lowest_price'), 10, 1); |
|
| 39 | 39 | |
| 40 | 40 | // Adds the product types supported from the WooCommerce extension "Subscribe to All the Things". |
| 41 | - add_filter( 'wcss_product_types', array( __CLASS__, 'support_product_types_for_wc_satt' ), 10, 1 ); |
|
| 41 | + add_filter('wcss_product_types', array(__CLASS__, 'support_product_types_for_wc_satt'), 10, 1); |
|
| 42 | 42 | } // END init() |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | * @return array |
| 50 | 50 | */ |
| 51 | 51 | public static function get_supported_product_types() { |
| 52 | - return apply_filters( 'wcss_product_types', array( |
|
| 52 | + return apply_filters('wcss_product_types', array( |
|
| 53 | 53 | 'subscription', |
| 54 | 54 | 'subscription-variation', |
| 55 | - ) ); |
|
| 55 | + )); |
|
| 56 | 56 | } // END get_supported_product_types() |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -63,15 +63,15 @@ discard block |
||
| 63 | 63 | * @param object $product |
| 64 | 64 | * @return bool |
| 65 | 65 | */ |
| 66 | - public static function force_is_subscription( $is_subscription, $product_id, $product ) { |
|
| 66 | + public static function force_is_subscription($is_subscription, $product_id, $product) { |
|
| 67 | 67 | /*if ( is_object( $product ) ) { |
| 68 | 68 | $product = $product; |
| 69 | 69 | } elseif ( is_numeric( $product_id ) ) { |
| 70 | 70 | $product = wc_get_product( $product_id ); |
| 71 | 71 | }*/ |
| 72 | 72 | |
| 73 | - if ( in_array( $product->product_type, self::get_supported_product_types() ) ) { |
|
| 74 | - if ( class_exists( 'WCS_ATT_Schemes' ) && WCS_ATT_Schemes::get_product_subscription_schemes( $product ) ) { |
|
| 73 | + if (in_array($product->product_type, self::get_supported_product_types())) { |
|
| 74 | + if (class_exists('WCS_ATT_Schemes') && WCS_ATT_Schemes::get_product_subscription_schemes($product)) { |
|
| 75 | 75 | $is_subscription = true; |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | * @param WC_Product $product |
| 86 | 86 | * @return string |
| 87 | 87 | */ |
| 88 | - public static function get_price( $product ) { |
|
| 89 | - if ( WC_Subscriptions_Product::get_price( $product->id ) > 0 ) { |
|
| 88 | + public static function get_price($product) { |
|
| 89 | + if (WC_Subscriptions_Product::get_price($product->id) > 0) { |
|
| 90 | 90 | |
| 91 | - return ecs_html( WC_Subscriptions_Product::get_price( $product->id, array( |
|
| 91 | + return ecs_html(WC_Subscriptions_Product::get_price($product->id, array( |
|
| 92 | 92 | 'subscription_period' => false, |
| 93 | 93 | 'subscription_length' => false, |
| 94 | 94 | 'sign_up_fee' => false, |
| 95 | 95 | 'trial_length' => false, |
| 96 | - ) ) ); |
|
| 96 | + ))); |
|
| 97 | 97 | |
| 98 | 98 | } else { |
| 99 | 99 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * hooked: get_satt_lowest_price - 10 |
| 104 | 104 | */ |
| 105 | - do_action( 'woocommerce_subscriptions_shortcode_get_price', $product ); |
|
| 105 | + do_action('woocommerce_subscriptions_shortcode_get_price', $product); |
|
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | } // END get_price() |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | * @param WC_Product $product |
| 115 | 115 | * @return string |
| 116 | 116 | */ |
| 117 | - public static function get_satt_lowest_scheme_data( $product ) { |
|
| 118 | - if ( class_exists( 'WCS_ATT_Schemes' ) && class_exists( 'WCS_ATT_Scheme_Prices' ) ) { |
|
| 119 | - $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes( $product ); |
|
| 117 | + public static function get_satt_lowest_scheme_data($product) { |
|
| 118 | + if (class_exists('WCS_ATT_Schemes') && class_exists('WCS_ATT_Scheme_Prices')) { |
|
| 119 | + $product_level_schemes = WCS_ATT_Schemes::get_product_subscription_schemes($product); |
|
| 120 | 120 | |
| 121 | - return WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data( $product, $product_level_schemes ); |
|
| 121 | + return WCS_ATT_Scheme_Prices::get_lowest_price_subscription_scheme_data($product, $product_level_schemes); |
|
| 122 | 122 | } |
| 123 | 123 | } // END get_satt_lowest_scheme() |
| 124 | 124 | |
@@ -129,42 +129,42 @@ discard block |
||
| 129 | 129 | * @param WC_Product $product |
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | - public static function get_satt_lowest_price( $product ) { |
|
| 133 | - $scheme = self::get_satt_lowest_scheme_data( $product ); |
|
| 132 | + public static function get_satt_lowest_price($product) { |
|
| 133 | + $scheme = self::get_satt_lowest_scheme_data($product); |
|
| 134 | 134 | |
| 135 | - if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
| 135 | + if ( ! empty($scheme) && is_array($scheme)) { |
|
| 136 | 136 | // Override price? |
| 137 | - $override = $scheme['scheme']['subscription_pricing_method']; |
|
| 137 | + $override = $scheme[ 'scheme' ][ 'subscription_pricing_method' ]; |
|
| 138 | 138 | |
| 139 | 139 | // Discount? |
| 140 | - $discount = $scheme['scheme']['subscription_discount']; |
|
| 140 | + $discount = $scheme[ 'scheme' ][ 'subscription_discount' ]; |
|
| 141 | 141 | |
| 142 | 142 | // Prices |
| 143 | 143 | $prices = array( |
| 144 | - 'price' => $scheme['price'], |
|
| 145 | - 'regular_price' => $scheme['regular_price'], |
|
| 146 | - 'sale_price' => $scheme['sale_price'], |
|
| 147 | - 'subscription_price' => $scheme['scheme']['subscription_price'], |
|
| 148 | - 'subscription_regular_price' => $scheme['scheme']['subscription_regular_price'], |
|
| 149 | - 'subscription_sale_price' => $scheme['scheme']['subscription_sale_price'] |
|
| 144 | + 'price' => $scheme[ 'price' ], |
|
| 145 | + 'regular_price' => $scheme[ 'regular_price' ], |
|
| 146 | + 'sale_price' => $scheme[ 'sale_price' ], |
|
| 147 | + 'subscription_price' => $scheme[ 'scheme' ][ 'subscription_price' ], |
|
| 148 | + 'subscription_regular_price' => $scheme[ 'scheme' ][ 'subscription_regular_price' ], |
|
| 149 | + 'subscription_sale_price' => $scheme[ 'scheme' ][ 'subscription_sale_price' ] |
|
| 150 | 150 | ); |
| 151 | 151 | |
| 152 | 152 | // Prepare the price |
| 153 | 153 | $price = ''; |
| 154 | 154 | |
| 155 | - if ( 'inherit' == $override ) { |
|
| 156 | - $price = empty( $discount ) ? $price : ( empty( $prices[ 'regular_price' ] ) ? $prices[ 'regular_price' ] : round( ( double ) $prices[ 'regular_price' ] * ( 100 - $discount ) / 100, wc_get_price_decimals() ) ); |
|
| 157 | - } else if ( 'override' == $override ) { |
|
| 158 | - $price = $prices['subscription_price']; |
|
| 155 | + if ('inherit' == $override) { |
|
| 156 | + $price = empty($discount) ? $price : (empty($prices[ 'regular_price' ]) ? $prices[ 'regular_price' ] : round((double) $prices[ 'regular_price' ] * (100 - $discount) / 100, wc_get_price_decimals())); |
|
| 157 | + } else if ('override' == $override) { |
|
| 158 | + $price = $prices[ 'subscription_price' ]; |
|
| 159 | 159 | |
| 160 | - if ( $prices[ 'subscription_price' ] < $prices[ 'subscription_regular_price' ] ) { |
|
| 160 | + if ($prices[ 'subscription_price' ] < $prices[ 'subscription_regular_price' ]) { |
|
| 161 | 161 | $price = $prices[ 'subscription_sale_price' ]; |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // If the price is returned as an array, return just the first. |
| 166 | - if ( is_array( $price ) ) { |
|
| 167 | - $price = $price[0]; |
|
| 166 | + if (is_array($price)) { |
|
| 167 | + $price = $price[ 0 ]; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | return $price; |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | * @param array $atts |
| 181 | 181 | * @return string |
| 182 | 182 | */ |
| 183 | - public static function get_subscription_price( $atts ) { |
|
| 183 | + public static function get_subscription_price($atts) { |
|
| 184 | 184 | global $wpdb, $post; |
| 185 | 185 | |
| 186 | - $defaults = shortcode_atts( array( |
|
| 186 | + $defaults = shortcode_atts(array( |
|
| 187 | 187 | 'id' => '', |
| 188 | 188 | 'sku' => '', |
| 189 | 189 | 'period' => false, |
@@ -192,47 +192,47 @@ discard block |
||
| 192 | 192 | 'trial_length' => false, |
| 193 | 193 | 'before_price' => '<span class="price subscription-price">', |
| 194 | 194 | 'after_price' => '</span>', |
| 195 | - ), $atts ); |
|
| 195 | + ), $atts); |
|
| 196 | 196 | |
| 197 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 197 | + $atts = wp_parse_args($atts, $defaults); |
|
| 198 | 198 | |
| 199 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 200 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 201 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 202 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 203 | - $product_data = get_post( $product_id ); |
|
| 199 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 200 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 201 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 202 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 203 | + $product_data = get_post($product_id); |
|
| 204 | 204 | } else { |
| 205 | - $product_data = wc_get_product( $post->ID ); |
|
| 205 | + $product_data = wc_get_product($post->ID); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Check that the product type is supported. Return blank if not supported. |
| 209 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 209 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 210 | 210 | return ''; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | ob_start(); |
| 214 | 214 | |
| 215 | - $price_html = WC_Subscriptions_Product::get_price_string( $product_data->id, array( |
|
| 216 | - 'price' => self::get_price( $product_data ), |
|
| 217 | - 'subscription_period' => isset( $atts['period'] ) ? $atts['period'] : true, |
|
| 218 | - 'subscription_length' => isset( $atts['length'] ) ? $atts['length'] : true, |
|
| 219 | - 'sign_up_fee' => isset( $atts['sign_up_fee'] ) ? $atts['sign_up_fee'] : true, |
|
| 220 | - 'trial_length' => isset( $atts['trial_length'] ) ? $atts['trial_length'] : true, |
|
| 221 | - ) ); |
|
| 215 | + $price_html = WC_Subscriptions_Product::get_price_string($product_data->id, array( |
|
| 216 | + 'price' => self::get_price($product_data), |
|
| 217 | + 'subscription_period' => isset($atts[ 'period' ]) ? $atts[ 'period' ] : true, |
|
| 218 | + 'subscription_length' => isset($atts[ 'length' ]) ? $atts[ 'length' ] : true, |
|
| 219 | + 'sign_up_fee' => isset($atts[ 'sign_up_fee' ]) ? $atts[ 'sign_up_fee' ] : true, |
|
| 220 | + 'trial_length' => isset($atts[ 'trial_length' ]) ? $atts[ 'trial_length' ] : true, |
|
| 221 | + )); |
|
| 222 | 222 | |
| 223 | 223 | // Clean the subscription price wrapper. |
| 224 | 224 | $price_html = str_replace('<span class="subscription-details">', '', $price_html); |
| 225 | 225 | $price_html = str_replace('</span">', '', $price_html); |
| 226 | 226 | |
| 227 | 227 | // Trim the whitespace. |
| 228 | - $price_html = trim( $price_html ); |
|
| 228 | + $price_html = trim($price_html); |
|
| 229 | 229 | |
| 230 | 230 | // Convert to Price Tag. |
| 231 | - $price_html = wc_price( $price_html ); |
|
| 231 | + $price_html = wc_price($price_html); |
|
| 232 | 232 | |
| 233 | - $price_html = sprintf( __( '%s%s%s', WCSS::TEXT_DOMAIN ), $atts['before_price'], $price_html, $atts['after_price'] ); |
|
| 233 | + $price_html = sprintf(__('%s%s%s', WCSS::TEXT_DOMAIN), $atts[ 'before_price' ], $price_html, $atts[ 'after_price' ]); |
|
| 234 | 234 | |
| 235 | - echo html_entity_decode( $price_html ); |
|
| 235 | + echo html_entity_decode($price_html); |
|
| 236 | 236 | |
| 237 | 237 | return ob_get_clean(); |
| 238 | 238 | } // END get_subscription_price() |
@@ -245,46 +245,46 @@ discard block |
||
| 245 | 245 | * @param array $atts |
| 246 | 246 | * @return string |
| 247 | 247 | */ |
| 248 | - public static function get_subscription_price_meta( $atts ) { |
|
| 248 | + public static function get_subscription_price_meta($atts) { |
|
| 249 | 249 | global $wpdb, $post; |
| 250 | 250 | |
| 251 | - $defaults = shortcode_atts( array( |
|
| 251 | + $defaults = shortcode_atts(array( |
|
| 252 | 252 | 'id' => '', |
| 253 | 253 | 'sku' => '', |
| 254 | 254 | 'meta' => 'both', |
| 255 | 255 | 'before_price' => '', |
| 256 | 256 | 'after_price' => '', |
| 257 | - ), $atts ); |
|
| 257 | + ), $atts); |
|
| 258 | 258 | |
| 259 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 259 | + $atts = wp_parse_args($atts, $defaults); |
|
| 260 | 260 | |
| 261 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 262 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 263 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 264 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 265 | - $product_data = get_post( $product_id ); |
|
| 261 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 262 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 263 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 264 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 265 | + $product_data = get_post($product_id); |
|
| 266 | 266 | } else { |
| 267 | - $product_data = wc_get_product( $post->ID ); |
|
| 267 | + $product_data = wc_get_product($post->ID); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // Check that the product type is supported. Return blank if not supported. |
| 271 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 271 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 272 | 272 | return ''; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | ob_start(); |
| 276 | 276 | |
| 277 | - $price = WC_Subscriptions_Product::get_price( $product_data->id ); |
|
| 277 | + $price = WC_Subscriptions_Product::get_price($product_data->id); |
|
| 278 | 278 | |
| 279 | 279 | // Remove the subscription price wrapper. |
| 280 | 280 | $price_html = str_replace('<span class="subscription-details">', '', $price); |
| 281 | 281 | $price = str_replace('</span">', '', $price_html); |
| 282 | 282 | |
| 283 | 283 | // If the subscription product has no price, then look for alternative. |
| 284 | - if ( empty( $price ) ) { |
|
| 285 | - $scheme = self::get_satt_lowest_scheme_data( $product_data ); |
|
| 284 | + if (empty($price)) { |
|
| 285 | + $scheme = self::get_satt_lowest_scheme_data($product_data); |
|
| 286 | 286 | |
| 287 | - if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
| 287 | + if ( ! empty($scheme) && is_array($scheme)) { |
|
| 288 | 288 | |
| 289 | 289 | // These values will be overridden. They are defined here to acknowledge their existence. |
| 290 | 290 | $price = ''; |
@@ -292,30 +292,30 @@ discard block |
||
| 292 | 292 | $sale_price = ''; |
| 293 | 293 | |
| 294 | 294 | $prices = array( |
| 295 | - 'price' => $scheme['price'], |
|
| 296 | - 'regular_price' => $scheme['regular_price'], |
|
| 297 | - 'sale_price' => $scheme['sale_price'], |
|
| 298 | - 'method' => $scheme['scheme']['subscription_pricing_method'], |
|
| 299 | - 'subscription_price' => $scheme['scheme']['subscription_price'], |
|
| 300 | - 'subscription_regular_price' => $scheme['scheme']['subscription_regular_price'], |
|
| 301 | - 'subscription_sale_price' => $scheme['scheme']['subscription_sale_price'] |
|
| 295 | + 'price' => $scheme[ 'price' ], |
|
| 296 | + 'regular_price' => $scheme[ 'regular_price' ], |
|
| 297 | + 'sale_price' => $scheme[ 'sale_price' ], |
|
| 298 | + 'method' => $scheme[ 'scheme' ][ 'subscription_pricing_method' ], |
|
| 299 | + 'subscription_price' => $scheme[ 'scheme' ][ 'subscription_price' ], |
|
| 300 | + 'subscription_regular_price' => $scheme[ 'scheme' ][ 'subscription_regular_price' ], |
|
| 301 | + 'subscription_sale_price' => $scheme[ 'scheme' ][ 'subscription_sale_price' ] |
|
| 302 | 302 | ); |
| 303 | 303 | |
| 304 | 304 | // Return the subscription price based on the pricing method. |
| 305 | - switch( $prices['method'] ) { |
|
| 305 | + switch ($prices[ 'method' ]) { |
|
| 306 | 306 | case 'override': |
| 307 | - $price = $prices['subscription_price']; |
|
| 308 | - $regular_price = $prices['subscription_regular_price']; |
|
| 309 | - $sale_price = $prices['subscription_sale_price']; |
|
| 307 | + $price = $prices[ 'subscription_price' ]; |
|
| 308 | + $regular_price = $prices[ 'subscription_regular_price' ]; |
|
| 309 | + $sale_price = $prices[ 'subscription_sale_price' ]; |
|
| 310 | 310 | break; |
| 311 | 311 | case 'inherit': |
| 312 | - $discount = $scheme['scheme']['subscription_discount']; |
|
| 313 | - $price = $prices['price']; |
|
| 314 | - $regular_price = $prices['regular_price']; |
|
| 315 | - $sale_price = $prices['sale_price']; |
|
| 312 | + $discount = $scheme[ 'scheme' ][ 'subscription_discount' ]; |
|
| 313 | + $price = $prices[ 'price' ]; |
|
| 314 | + $regular_price = $prices[ 'regular_price' ]; |
|
| 315 | + $sale_price = $prices[ 'sale_price' ]; |
|
| 316 | 316 | |
| 317 | - if ( !empty( $discount ) && $discount > 0 ) { |
|
| 318 | - $sale_price = round( ( double ) $regular_price * ( 100 - $discount ) / 100, wc_get_price_decimals() ); |
|
| 317 | + if ( ! empty($discount) && $discount > 0) { |
|
| 318 | + $sale_price = round((double) $regular_price * (100 - $discount) / 100, wc_get_price_decimals()); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | break; |
@@ -323,42 +323,42 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | // Display both the regular price striked out and the sale price |
| 325 | 325 | // should the active price be less than the regular price. |
| 326 | - if ( $atts['meta'] != 'active' && !empty( $sale_price ) && $price < $regular_price ) { |
|
| 327 | - $price = '<del>' . ( ( is_numeric( $regular_price ) ) ? wc_price( $regular_price ) : $regular_price ) . '</del> <ins>' . ( ( is_numeric( $sale_price ) ) ? wc_price( $sale_price ) : $sale_price ) . '</ins>'; |
|
| 326 | + if ($atts[ 'meta' ] != 'active' && ! empty($sale_price) && $price < $regular_price) { |
|
| 327 | + $price = '<del>' . ((is_numeric($regular_price)) ? wc_price($regular_price) : $regular_price) . '</del> <ins>' . ((is_numeric($sale_price)) ? wc_price($sale_price) : $sale_price) . '</ins>'; |
|
| 328 | 328 | |
| 329 | 329 | // Trim the whitespace. |
| 330 | - $price = trim( $price ); |
|
| 330 | + $price = trim($price); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // Override the value should only one value be returned. |
| 334 | - if ( $atts['meta'] != 'both' ) { |
|
| 335 | - if ( $atts['meta'] == 'active' ) { |
|
| 334 | + if ($atts[ 'meta' ] != 'both') { |
|
| 335 | + if ($atts[ 'meta' ] == 'active') { |
|
| 336 | 336 | $price = $price; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - if ( $atts['meta'] == 'regular' ) { |
|
| 339 | + if ($atts[ 'meta' ] == 'regular') { |
|
| 340 | 340 | $price = $regular_price; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if ( $atts['meta'] == 'sale' ) { |
|
| 343 | + if ($atts[ 'meta' ] == 'sale') { |
|
| 344 | 344 | $price = $sale_price; |
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - if ( is_numeric( $price ) ) { |
|
| 349 | - $price = wc_price( $price ); |
|
| 348 | + if (is_numeric($price)) { |
|
| 349 | + $price = wc_price($price); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | // Clean the price tag. |
| 353 | - $price = self::clean_wc_price( $price ); |
|
| 353 | + $price = self::clean_wc_price($price); |
|
| 354 | 354 | |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - $price_html = sprintf( __( '%s%s%s', WCSS::TEXT_DOMAIN ), $atts['before_price'], $price, $atts['after_price'] ); |
|
| 359 | + $price_html = sprintf(__('%s%s%s', WCSS::TEXT_DOMAIN), $atts[ 'before_price' ], $price, $atts[ 'after_price' ]); |
|
| 360 | 360 | |
| 361 | - echo html_entity_decode( $price_html ); |
|
| 361 | + echo html_entity_decode($price_html); |
|
| 362 | 362 | |
| 363 | 363 | return ob_get_clean(); |
| 364 | 364 | } // END get_subscription_price_meta() |
@@ -371,27 +371,27 @@ discard block |
||
| 371 | 371 | * @param array $atts |
| 372 | 372 | * @return string |
| 373 | 373 | */ |
| 374 | - public static function get_subscription_discount( $atts ) { |
|
| 374 | + public static function get_subscription_discount($atts) { |
|
| 375 | 375 | global $wpdb, $post; |
| 376 | 376 | |
| 377 | - $defaults = shortcode_atts( array( |
|
| 377 | + $defaults = shortcode_atts(array( |
|
| 378 | 378 | 'id' => '', |
| 379 | 379 | 'sku' => '', |
| 380 | - ), $atts ); |
|
| 380 | + ), $atts); |
|
| 381 | 381 | |
| 382 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 382 | + $atts = wp_parse_args($atts, $defaults); |
|
| 383 | 383 | |
| 384 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 385 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 386 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 387 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 388 | - $product_data = get_post( $product_id ); |
|
| 384 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 385 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 386 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 387 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 388 | + $product_data = get_post($product_id); |
|
| 389 | 389 | } else { |
| 390 | - $product_data = wc_get_product( $post->ID ); |
|
| 390 | + $product_data = wc_get_product($post->ID); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | // Check that the product type is supported. Return blank if not supported. |
| 394 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 394 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 395 | 395 | return ''; |
| 396 | 396 | } |
| 397 | 397 | |
@@ -401,18 +401,18 @@ discard block |
||
| 401 | 401 | $discount = ''; // Returns empty by default. |
| 402 | 402 | |
| 403 | 403 | // Get Subscription Discount - Only available with the WooCommerce extension "Subscribe to All the Things". |
| 404 | - $scheme = self::get_satt_lowest_scheme_data( $product_data ); |
|
| 404 | + $scheme = self::get_satt_lowest_scheme_data($product_data); |
|
| 405 | 405 | |
| 406 | - if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
| 406 | + if ( ! empty($scheme) && is_array($scheme)) { |
|
| 407 | 407 | // Override price? |
| 408 | - $override = $scheme['scheme']['subscription_pricing_method']; |
|
| 408 | + $override = $scheme[ 'scheme' ][ 'subscription_pricing_method' ]; |
|
| 409 | 409 | |
| 410 | 410 | // Discount ? |
| 411 | - $discount = $scheme['scheme']['subscription_discount']; |
|
| 411 | + $discount = $scheme[ 'scheme' ][ 'subscription_discount' ]; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - if ( ! empty( $discount ) && is_numeric( $discount ) && $override == 'inherit' ) { |
|
| 415 | - $discount = sprintf( __( '%s%s %s', WCSS::TEXT_DOMAIN ), $discount, '%', apply_filters( 'wcs_shortcodes_sub_discount_string', __( 'discount', WCSS::TEXT_DOMAIN ) ) ); |
|
| 414 | + if ( ! empty($discount) && is_numeric($discount) && $override == 'inherit') { |
|
| 415 | + $discount = sprintf(__('%s%s %s', WCSS::TEXT_DOMAIN), $discount, '%', apply_filters('wcs_shortcodes_sub_discount_string', __('discount', WCSS::TEXT_DOMAIN))); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | echo $discount; |
@@ -426,47 +426,47 @@ discard block |
||
| 426 | 426 | * @param array $atts |
| 427 | 427 | * @return string |
| 428 | 428 | */ |
| 429 | - public static function get_subscription_period( $atts ) { |
|
| 429 | + public static function get_subscription_period($atts) { |
|
| 430 | 430 | global $wpdb, $post; |
| 431 | 431 | |
| 432 | - $defaults = shortcode_atts( array( |
|
| 432 | + $defaults = shortcode_atts(array( |
|
| 433 | 433 | 'id' => '', |
| 434 | 434 | 'sku' => '', |
| 435 | 435 | 'raw' => false |
| 436 | - ), $atts ); |
|
| 436 | + ), $atts); |
|
| 437 | 437 | |
| 438 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 438 | + $atts = wp_parse_args($atts, $defaults); |
|
| 439 | 439 | |
| 440 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 441 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 442 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 443 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 444 | - $product_data = get_post( $product_id ); |
|
| 440 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 441 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 442 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 443 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 444 | + $product_data = get_post($product_id); |
|
| 445 | 445 | } else { |
| 446 | - $product_data = wc_get_product( $post->ID ); |
|
| 446 | + $product_data = wc_get_product($post->ID); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // Check that the product type is supported. Return blank if not supported. |
| 450 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 450 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 451 | 451 | return ''; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | ob_start(); |
| 455 | 455 | |
| 456 | 456 | // Get Subscription Period |
| 457 | - $period = WC_Subscriptions_Product::get_period( $product_data ); |
|
| 457 | + $period = WC_Subscriptions_Product::get_period($product_data); |
|
| 458 | 458 | |
| 459 | 459 | // If the period is empty, look for alternative. |
| 460 | - if ( empty( $period ) ) { |
|
| 461 | - $scheme = self::get_satt_lowest_scheme_data( $product_data ); |
|
| 460 | + if (empty($period)) { |
|
| 461 | + $scheme = self::get_satt_lowest_scheme_data($product_data); |
|
| 462 | 462 | |
| 463 | - if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
| 464 | - $period = $scheme['scheme']['subscription_period']; |
|
| 463 | + if ( ! empty($scheme) && is_array($scheme)) { |
|
| 464 | + $period = $scheme[ 'scheme' ][ 'subscription_period' ]; |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if ( ! $atts['raw'] ) { |
|
| 469 | - $period = sprintf( __( 'Per %s', WCSS::TEXT_DOMAIN ), $period ); |
|
| 468 | + if ( ! $atts[ 'raw' ]) { |
|
| 469 | + $period = sprintf(__('Per %s', WCSS::TEXT_DOMAIN), $period); |
|
| 470 | 470 | $period = ucwords($period); |
| 471 | 471 | } |
| 472 | 472 | |
@@ -481,41 +481,41 @@ discard block |
||
| 481 | 481 | * @param array $atts |
| 482 | 482 | * @return string |
| 483 | 483 | */ |
| 484 | - public static function get_subscription_period_interval( $atts ) { |
|
| 484 | + public static function get_subscription_period_interval($atts) { |
|
| 485 | 485 | global $wpdb, $post; |
| 486 | 486 | |
| 487 | - $defaults = shortcode_atts( array( |
|
| 487 | + $defaults = shortcode_atts(array( |
|
| 488 | 488 | 'id' => '', |
| 489 | 489 | 'sku' => '', |
| 490 | - ), $atts ); |
|
| 490 | + ), $atts); |
|
| 491 | 491 | |
| 492 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 492 | + $atts = wp_parse_args($atts, $defaults); |
|
| 493 | 493 | |
| 494 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 495 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 496 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 497 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 498 | - $product_data = get_post( $product_id ); |
|
| 494 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 495 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 496 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 497 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 498 | + $product_data = get_post($product_id); |
|
| 499 | 499 | } else { |
| 500 | - $product_data = wc_get_product( $post->ID ); |
|
| 500 | + $product_data = wc_get_product($post->ID); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | // Check that the product type is supported. Return blank if not supported. |
| 504 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 504 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 505 | 505 | return ''; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | ob_start(); |
| 509 | 509 | |
| 510 | 510 | // Get Subscription Period Interval |
| 511 | - $period_interval = WC_Subscriptions_Product::get_interval( $product_data ); |
|
| 511 | + $period_interval = WC_Subscriptions_Product::get_interval($product_data); |
|
| 512 | 512 | |
| 513 | 513 | // If the period is empty, look for alternative. |
| 514 | - if ( empty( $period_interval ) ) { |
|
| 515 | - $scheme = self::get_satt_lowest_scheme_data( $product_data ); |
|
| 514 | + if (empty($period_interval)) { |
|
| 515 | + $scheme = self::get_satt_lowest_scheme_data($product_data); |
|
| 516 | 516 | |
| 517 | - if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
| 518 | - $period_interval = $scheme['scheme']['subscription_period_interval']; |
|
| 517 | + if ( ! empty($scheme) && is_array($scheme)) { |
|
| 518 | + $period_interval = $scheme[ 'scheme' ][ 'subscription_period_interval' ]; |
|
| 519 | 519 | } |
| 520 | 520 | } |
| 521 | 521 | |
@@ -530,52 +530,52 @@ discard block |
||
| 530 | 530 | * @param array $atts |
| 531 | 531 | * @return string |
| 532 | 532 | */ |
| 533 | - public static function get_subscription_length( $atts ) { |
|
| 533 | + public static function get_subscription_length($atts) { |
|
| 534 | 534 | global $wpdb, $post; |
| 535 | 535 | |
| 536 | - $defaults = shortcode_atts( array( |
|
| 536 | + $defaults = shortcode_atts(array( |
|
| 537 | 537 | 'id' => '', |
| 538 | 538 | 'sku' => '', |
| 539 | 539 | 'raw' => false, |
| 540 | - ), $atts ); |
|
| 540 | + ), $atts); |
|
| 541 | 541 | |
| 542 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 542 | + $atts = wp_parse_args($atts, $defaults); |
|
| 543 | 543 | |
| 544 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 545 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 546 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 547 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 548 | - $product_data = get_post( $product_id ); |
|
| 544 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 545 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 546 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 547 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 548 | + $product_data = get_post($product_id); |
|
| 549 | 549 | } else { |
| 550 | - $product_data = wc_get_product( $post->ID ); |
|
| 550 | + $product_data = wc_get_product($post->ID); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | // Check that the product type is supported. Return blank if not supported. |
| 554 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 554 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 555 | 555 | return ''; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | ob_start(); |
| 559 | 559 | |
| 560 | 560 | // Get Subscription Length |
| 561 | - $length = WC_Subscriptions_Product::get_length( $product_data ); |
|
| 561 | + $length = WC_Subscriptions_Product::get_length($product_data); |
|
| 562 | 562 | |
| 563 | 563 | // If the length is empty, look for alternative. |
| 564 | - if ( empty( $length ) ) { |
|
| 565 | - $scheme = self::get_satt_lowest_scheme_data( $product_data ); |
|
| 564 | + if (empty($length)) { |
|
| 565 | + $scheme = self::get_satt_lowest_scheme_data($product_data); |
|
| 566 | 566 | |
| 567 | - if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
| 567 | + if ( ! empty($scheme) && is_array($scheme)) { |
|
| 568 | 568 | |
| 569 | - $period = self::get_subscription_period( array( 'id' => $product_data->id, 'raw' => true ) ); |
|
| 570 | - $length = $scheme['scheme']['subscription_length']; |
|
| 569 | + $period = self::get_subscription_period(array('id' => $product_data->id, 'raw' => true)); |
|
| 570 | + $length = $scheme[ 'scheme' ][ 'subscription_length' ]; |
|
| 571 | 571 | |
| 572 | 572 | // If we are not returning raw data then making it readable for humans. |
| 573 | - if ( ! $atts['raw'] ) { |
|
| 573 | + if ( ! $atts[ 'raw' ]) { |
|
| 574 | 574 | |
| 575 | - if ( $length > 0 ) { |
|
| 576 | - $length = sprintf( '%s %s', $length, $period ); |
|
| 575 | + if ($length > 0) { |
|
| 576 | + $length = sprintf('%s %s', $length, $period); |
|
| 577 | 577 | } else { |
| 578 | - $length = sprintf( __( 'Every %s', WCSS::TEXT_DOMAIN ), $period ); |
|
| 578 | + $length = sprintf(__('Every %s', WCSS::TEXT_DOMAIN), $period); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | $length = ucfirst($length); |
@@ -597,59 +597,59 @@ discard block |
||
| 597 | 597 | * @param array $atts |
| 598 | 598 | * @return string |
| 599 | 599 | */ |
| 600 | - public static function get_subscription_sign_up_fee( $atts ) { |
|
| 600 | + public static function get_subscription_sign_up_fee($atts) { |
|
| 601 | 601 | global $wpdb, $post; |
| 602 | 602 | |
| 603 | - $defaults = shortcode_atts( array( |
|
| 603 | + $defaults = shortcode_atts(array( |
|
| 604 | 604 | 'id' => '', |
| 605 | 605 | 'sku' => '', |
| 606 | 606 | 'raw' => false, |
| 607 | 607 | 'before_price' => '', |
| 608 | 608 | 'after_price' => '', |
| 609 | - ), $atts ); |
|
| 609 | + ), $atts); |
|
| 610 | 610 | |
| 611 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 611 | + $atts = wp_parse_args($atts, $defaults); |
|
| 612 | 612 | |
| 613 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 614 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 615 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 616 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 617 | - $product_data = get_post( $product_id ); |
|
| 613 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 614 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 615 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 616 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 617 | + $product_data = get_post($product_id); |
|
| 618 | 618 | } else { |
| 619 | - $product_data = wc_get_product( $post->ID ); |
|
| 619 | + $product_data = wc_get_product($post->ID); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | // Check that the product type is supported. Return blank if not supported. |
| 623 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 623 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 624 | 624 | return ''; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | ob_start(); |
| 628 | 628 | |
| 629 | 629 | // Get Subscription Sign Up Fee |
| 630 | - $sign_up_fee = WC_Subscriptions_Product::get_sign_up_fee( $product_data ); |
|
| 630 | + $sign_up_fee = WC_Subscriptions_Product::get_sign_up_fee($product_data); |
|
| 631 | 631 | |
| 632 | 632 | // If the sign up fee is empty, look for alternative. |
| 633 | - if ( empty( $sign_up_fee ) ) { |
|
| 634 | - $scheme = self::get_satt_lowest_scheme_data( $product_data ); |
|
| 633 | + if (empty($sign_up_fee)) { |
|
| 634 | + $scheme = self::get_satt_lowest_scheme_data($product_data); |
|
| 635 | 635 | |
| 636 | - if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
| 637 | - $sign_up_fee = $scheme['scheme']['subscription_sign_up_fee']; |
|
| 636 | + if ( ! empty($scheme) && is_array($scheme)) { |
|
| 637 | + $sign_up_fee = $scheme[ 'scheme' ][ 'subscription_sign_up_fee' ]; |
|
| 638 | 638 | } |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - if ( ! $atts['raw'] ) { |
|
| 641 | + if ( ! $atts[ 'raw' ]) { |
|
| 642 | 642 | // Convert number into a price tag. |
| 643 | - if ( is_numeric( $sign_up_fee ) ) { |
|
| 644 | - $sign_up_fee = wc_price( $sign_up_fee ); |
|
| 643 | + if (is_numeric($sign_up_fee)) { |
|
| 644 | + $sign_up_fee = wc_price($sign_up_fee); |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | // Clean the price tag. |
| 648 | - $sign_up_fee = self::clean_wc_price( $sign_up_fee ); |
|
| 648 | + $sign_up_fee = self::clean_wc_price($sign_up_fee); |
|
| 649 | 649 | |
| 650 | - $price_html = sprintf( __( '%s%s%s', WCSS::TEXT_DOMAIN ), $atts['before_price'], $sign_up_fee, $atts['after_price'] ); |
|
| 650 | + $price_html = sprintf(__('%s%s%s', WCSS::TEXT_DOMAIN), $atts[ 'before_price' ], $sign_up_fee, $atts[ 'after_price' ]); |
|
| 651 | 651 | |
| 652 | - $sign_up_fee = html_entity_decode( $price_html ); |
|
| 652 | + $sign_up_fee = html_entity_decode($price_html); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | echo $sign_up_fee; |
@@ -663,55 +663,55 @@ discard block |
||
| 663 | 663 | * @param array $atts |
| 664 | 664 | * @return string |
| 665 | 665 | */ |
| 666 | - public static function get_subscription_trial_string( $atts ) { |
|
| 666 | + public static function get_subscription_trial_string($atts) { |
|
| 667 | 667 | global $wpdb, $post; |
| 668 | 668 | |
| 669 | - $defaults = shortcode_atts( array( |
|
| 669 | + $defaults = shortcode_atts(array( |
|
| 670 | 670 | 'id' => '', |
| 671 | 671 | 'sku' => '', |
| 672 | - ), $atts ); |
|
| 672 | + ), $atts); |
|
| 673 | 673 | |
| 674 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 674 | + $atts = wp_parse_args($atts, $defaults); |
|
| 675 | 675 | |
| 676 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 677 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 678 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 679 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 680 | - $product_data = get_post( $product_id ); |
|
| 676 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 677 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 678 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 679 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 680 | + $product_data = get_post($product_id); |
|
| 681 | 681 | } else { |
| 682 | - $product_data = wc_get_product( $post->ID ); |
|
| 682 | + $product_data = wc_get_product($post->ID); |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | // Check that the product type is supported. Return blank if not supported. |
| 686 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 686 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 687 | 687 | return ''; |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | ob_start(); |
| 691 | 691 | |
| 692 | 692 | // Get Subscription Trial Length |
| 693 | - $trial_length = self::get_subscription_trial_length( array( 'id' => $product_data->id ) ); |
|
| 693 | + $trial_length = self::get_subscription_trial_length(array('id' => $product_data->id)); |
|
| 694 | 694 | |
| 695 | 695 | // Get Subscription Trial Period |
| 696 | - $trial_period = self::get_subscription_trial_period( array( 'id' => $product_data->id, 'raw' => true ) ); |
|
| 696 | + $trial_period = self::get_subscription_trial_period(array('id' => $product_data->id, 'raw' => true)); |
|
| 697 | 697 | |
| 698 | - if ( ! empty( $trial_length ) && $trial_length > 0 ) { |
|
| 698 | + if ( ! empty($trial_length) && $trial_length > 0) { |
|
| 699 | 699 | |
| 700 | - switch ( $trial_period ) { |
|
| 700 | + switch ($trial_period) { |
|
| 701 | 701 | case 'day': |
| 702 | - echo sprintf( _n( '%s day', '%s days', $trial_length, WCSS::TEXT_DOMAIN ), $trial_length ); |
|
| 702 | + echo sprintf(_n('%s day', '%s days', $trial_length, WCSS::TEXT_DOMAIN), $trial_length); |
|
| 703 | 703 | break; |
| 704 | 704 | |
| 705 | 705 | case 'week': |
| 706 | - echo sprintf( _n( '%s week', '%s weeks', $trial_length, WCSS::TEXT_DOMAIN ), $trial_length ); |
|
| 706 | + echo sprintf(_n('%s week', '%s weeks', $trial_length, WCSS::TEXT_DOMAIN), $trial_length); |
|
| 707 | 707 | break; |
| 708 | 708 | |
| 709 | 709 | case 'month': |
| 710 | - echo sprintf( _n( '%s month', '%s months', $trial_length, WCSS::TEXT_DOMAIN ), $trial_length ); |
|
| 710 | + echo sprintf(_n('%s month', '%s months', $trial_length, WCSS::TEXT_DOMAIN), $trial_length); |
|
| 711 | 711 | break; |
| 712 | 712 | |
| 713 | 713 | case 'year': |
| 714 | - echo sprintf( _n( '%s year', '%s years', $trial_length, WCSS::TEXT_DOMAIN ), $trial_length ); |
|
| 714 | + echo sprintf(_n('%s year', '%s years', $trial_length, WCSS::TEXT_DOMAIN), $trial_length); |
|
| 715 | 715 | break; |
| 716 | 716 | } |
| 717 | 717 | |
@@ -726,41 +726,41 @@ discard block |
||
| 726 | 726 | * @param array $atts |
| 727 | 727 | * @return string |
| 728 | 728 | */ |
| 729 | - public static function get_subscription_trial_length( $atts ) { |
|
| 729 | + public static function get_subscription_trial_length($atts) { |
|
| 730 | 730 | global $wpdb, $post; |
| 731 | 731 | |
| 732 | - $defaults = shortcode_atts( array( |
|
| 732 | + $defaults = shortcode_atts(array( |
|
| 733 | 733 | 'id' => '', |
| 734 | 734 | 'sku' => '', |
| 735 | - ), $atts ); |
|
| 735 | + ), $atts); |
|
| 736 | 736 | |
| 737 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 737 | + $atts = wp_parse_args($atts, $defaults); |
|
| 738 | 738 | |
| 739 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 740 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 741 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 742 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 743 | - $product_data = get_post( $product_id ); |
|
| 739 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 740 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 741 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 742 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 743 | + $product_data = get_post($product_id); |
|
| 744 | 744 | } else { |
| 745 | - $product_data = wc_get_product( $post->ID ); |
|
| 745 | + $product_data = wc_get_product($post->ID); |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | // Check that the product type is supported. Return blank if not supported. |
| 749 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 749 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 750 | 750 | return ''; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | ob_start(); |
| 754 | 754 | |
| 755 | 755 | // Get Subscription Trial Length |
| 756 | - $trial_length = WC_Subscriptions_Product::get_trial_length( $product_data ); |
|
| 756 | + $trial_length = WC_Subscriptions_Product::get_trial_length($product_data); |
|
| 757 | 757 | |
| 758 | 758 | // If the trial length is empty, look for alternative. |
| 759 | - if ( empty( $trial_length ) ) { |
|
| 760 | - $scheme = self::get_satt_lowest_scheme_data( $product_data ); |
|
| 759 | + if (empty($trial_length)) { |
|
| 760 | + $scheme = self::get_satt_lowest_scheme_data($product_data); |
|
| 761 | 761 | |
| 762 | - if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
| 763 | - $trial_length = $scheme['scheme']['subscription_trial_length']; |
|
| 762 | + if ( ! empty($scheme) && is_array($scheme)) { |
|
| 763 | + $trial_length = $scheme[ 'scheme' ][ 'subscription_trial_length' ]; |
|
| 764 | 764 | } |
| 765 | 765 | } |
| 766 | 766 | |
@@ -775,52 +775,52 @@ discard block |
||
| 775 | 775 | * @param array $atts |
| 776 | 776 | * @return string |
| 777 | 777 | */ |
| 778 | - public static function get_subscription_trial_period( $atts ) { |
|
| 778 | + public static function get_subscription_trial_period($atts) { |
|
| 779 | 779 | global $wpdb, $post; |
| 780 | 780 | |
| 781 | - $defaults = shortcode_atts( array( |
|
| 781 | + $defaults = shortcode_atts(array( |
|
| 782 | 782 | 'id' => '', |
| 783 | 783 | 'sku' => '', |
| 784 | 784 | 'raw' => false, |
| 785 | - ), $atts ); |
|
| 785 | + ), $atts); |
|
| 786 | 786 | |
| 787 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 787 | + $atts = wp_parse_args($atts, $defaults); |
|
| 788 | 788 | |
| 789 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 790 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 791 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 792 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 793 | - $product_data = get_post( $product_id ); |
|
| 789 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 790 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 791 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 792 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 793 | + $product_data = get_post($product_id); |
|
| 794 | 794 | } else { |
| 795 | - $product_data = wc_get_product( $post->ID ); |
|
| 795 | + $product_data = wc_get_product($post->ID); |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | // Check that the product type is supported. Return blank if not supported. |
| 799 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 799 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 800 | 800 | return ''; |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | ob_start(); |
| 804 | 804 | |
| 805 | 805 | // Get Subscription Trial Length |
| 806 | - $trial_length = self::get_subscription_trial_length( array( 'id' => $product_data->id ) ); |
|
| 806 | + $trial_length = self::get_subscription_trial_length(array('id' => $product_data->id)); |
|
| 807 | 807 | |
| 808 | 808 | // Get Subscription Trial Period |
| 809 | - $trial_period = WC_Subscriptions_Product::get_trial_period( $product_data ); |
|
| 809 | + $trial_period = WC_Subscriptions_Product::get_trial_period($product_data); |
|
| 810 | 810 | |
| 811 | 811 | // If the trial length is empty or is not zero, look for alternative. |
| 812 | - if ( empty( $trial_length ) || $trial_length != 0 ) { |
|
| 813 | - $scheme = self::get_satt_lowest_scheme_data( $product_data ); |
|
| 812 | + if (empty($trial_length) || $trial_length != 0) { |
|
| 813 | + $scheme = self::get_satt_lowest_scheme_data($product_data); |
|
| 814 | 814 | |
| 815 | - if ( !empty( $scheme ) && is_array( $scheme ) ) { |
|
| 816 | - $trial_length = $scheme['scheme']['subscription_trial_length']; |
|
| 817 | - $trial_period = $scheme['scheme']['subscription_trial_period']; |
|
| 815 | + if ( ! empty($scheme) && is_array($scheme)) { |
|
| 816 | + $trial_length = $scheme[ 'scheme' ][ 'subscription_trial_length' ]; |
|
| 817 | + $trial_period = $scheme[ 'scheme' ][ 'subscription_trial_period' ]; |
|
| 818 | 818 | } |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - if ( ! empty( $trial_length ) && $trial_length > 0 ) { |
|
| 821 | + if ( ! empty($trial_length) && $trial_length > 0) { |
|
| 822 | 822 | |
| 823 | - if ( ! $atts['raw'] ) { |
|
| 823 | + if ( ! $atts[ 'raw' ]) { |
|
| 824 | 824 | $trial_period = ucfirst($trial_period); |
| 825 | 825 | } |
| 826 | 826 | |
@@ -837,62 +837,62 @@ discard block |
||
| 837 | 837 | * @param array $atts |
| 838 | 838 | * @return string |
| 839 | 839 | */ |
| 840 | - public static function get_subscription_first_payment( $atts ) { |
|
| 840 | + public static function get_subscription_first_payment($atts) { |
|
| 841 | 841 | global $wpdb, $post; |
| 842 | 842 | |
| 843 | - $defaults = shortcode_atts( array( |
|
| 843 | + $defaults = shortcode_atts(array( |
|
| 844 | 844 | 'id' => '', |
| 845 | 845 | 'sku' => '', |
| 846 | 846 | 'show_time' => false, |
| 847 | 847 | 'from_date' => '', |
| 848 | 848 | 'timezone' => 'gmt', |
| 849 | 849 | 'format' => 'timestamp' |
| 850 | - ), $atts ); |
|
| 850 | + ), $atts); |
|
| 851 | 851 | |
| 852 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 852 | + $atts = wp_parse_args($atts, $defaults); |
|
| 853 | 853 | |
| 854 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 855 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 856 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 857 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 858 | - $product_data = get_post( $product_id ); |
|
| 854 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 855 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 856 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 857 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 858 | + $product_data = get_post($product_id); |
|
| 859 | 859 | } else { |
| 860 | - $product_data = wc_get_product( $post->ID ); |
|
| 860 | + $product_data = wc_get_product($post->ID); |
|
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | // Check that the product type is supported. Return blank if not supported. |
| 864 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 864 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 865 | 865 | return ''; |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | ob_start(); |
| 869 | 869 | |
| 870 | - $billing_interval = self::get_subscription_period_interval( array( 'id' => $product_data->id ) ); |
|
| 871 | - $billing_length = self::get_subscription_length( array( 'id' => $product_data->id, 'raw' => true ) ); |
|
| 872 | - $trial_length = self::get_subscription_trial_length( array( 'id' => $product_data->id ) ); |
|
| 870 | + $billing_interval = self::get_subscription_period_interval(array('id' => $product_data->id)); |
|
| 871 | + $billing_length = self::get_subscription_length(array('id' => $product_data->id, 'raw' => true)); |
|
| 872 | + $trial_length = self::get_subscription_trial_length(array('id' => $product_data->id)); |
|
| 873 | 873 | |
| 874 | - $from_date = $atts['from_date']; |
|
| 874 | + $from_date = $atts[ 'from_date' ]; |
|
| 875 | 875 | |
| 876 | - if ( $billing_interval != $billing_length || $trial_length > 0 ) { |
|
| 877 | - if ( empty( $from_date ) ) { |
|
| 878 | - $from_date = gmdate( 'Y-m-d H:i:s' ); |
|
| 876 | + if ($billing_interval != $billing_length || $trial_length > 0) { |
|
| 877 | + if (empty($from_date)) { |
|
| 878 | + $from_date = gmdate('Y-m-d H:i:s'); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | // If the subscription has a free trial period, the first renewal is the same as the expiration of the free trial |
| 882 | - if ( $trial_length > 0 ) { |
|
| 883 | - $first_renewal_timestamp = strtotime( WC_Subscriptions_Product::get_trial_expiration_date( $product_data->id, $from_date ) ); |
|
| 882 | + if ($trial_length > 0) { |
|
| 883 | + $first_renewal_timestamp = strtotime(WC_Subscriptions_Product::get_trial_expiration_date($product_data->id, $from_date)); |
|
| 884 | 884 | } else { |
| 885 | - $from_timestamp = strtotime( $from_date ); |
|
| 886 | - $billing_period = self::get_subscription_period( array( 'id' => $product_data->id, 'raw' => true ) ); |
|
| 885 | + $from_timestamp = strtotime($from_date); |
|
| 886 | + $billing_period = self::get_subscription_period(array('id' => $product_data->id, 'raw' => true)); |
|
| 887 | 887 | |
| 888 | - if ( 'month' == $billing_period ) { |
|
| 889 | - $first_renewal_timestamp = wcs_add_months( $from_timestamp, $billing_interval ); |
|
| 888 | + if ('month' == $billing_period) { |
|
| 889 | + $first_renewal_timestamp = wcs_add_months($from_timestamp, $billing_interval); |
|
| 890 | 890 | } else { |
| 891 | - $first_renewal_timestamp = strtotime( "+ $billing_interval {$billing_period}s", $from_timestamp ); |
|
| 891 | + $first_renewal_timestamp = strtotime("+ $billing_interval {$billing_period}s", $from_timestamp); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | - if ( 'site' == $atts['timezone'] ) { |
|
| 895 | - $first_renewal_timestamp += ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); |
|
| 894 | + if ('site' == $atts[ 'timezone' ]) { |
|
| 895 | + $first_renewal_timestamp += (get_option('gmt_offset') * HOUR_IN_SECONDS); |
|
| 896 | 896 | } |
| 897 | 897 | } |
| 898 | 898 | } else { |
@@ -901,22 +901,22 @@ discard block |
||
| 901 | 901 | |
| 902 | 902 | $date_format = ''; // Will be overridden later on. |
| 903 | 903 | |
| 904 | - if ( $first_renewal_timestamp > 0 ) { |
|
| 905 | - if ( $atts['show_time'] ) { |
|
| 906 | - if ( 'timestamp' == $atts['format'] ) { |
|
| 904 | + if ($first_renewal_timestamp > 0) { |
|
| 905 | + if ($atts[ 'show_time' ]) { |
|
| 906 | + if ('timestamp' == $atts[ 'format' ]) { |
|
| 907 | 907 | $date_format = 'Y-m-d H:i:s'; |
| 908 | - } else if ( 'string' == $atts['format'] ) { |
|
| 908 | + } else if ('string' == $atts[ 'format' ]) { |
|
| 909 | 909 | $date_format = 'D jS M Y H:i A'; |
| 910 | 910 | } |
| 911 | 911 | } else { |
| 912 | - if ( 'timestamp' == $atts['format'] ) { |
|
| 912 | + if ('timestamp' == $atts[ 'format' ]) { |
|
| 913 | 913 | $date_format = 'Y-m-d'; |
| 914 | - } else if ( 'string' == $atts['format'] ) { |
|
| 914 | + } else if ('string' == $atts[ 'format' ]) { |
|
| 915 | 915 | $date_format = 'D jS M Y'; |
| 916 | 916 | } |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | - $first_payment = date( $date_format, $first_renewal_timestamp ); |
|
| 919 | + $first_payment = date($date_format, $first_renewal_timestamp); |
|
| 920 | 920 | } else { |
| 921 | 921 | $first_payment = ''; |
| 922 | 922 | } |
@@ -932,65 +932,65 @@ discard block |
||
| 932 | 932 | * @param array $atts |
| 933 | 933 | * @return string |
| 934 | 934 | */ |
| 935 | - public static function get_subscription_initial( $atts ) { |
|
| 935 | + public static function get_subscription_initial($atts) { |
|
| 936 | 936 | global $wpdb, $post; |
| 937 | 937 | |
| 938 | - $defaults = shortcode_atts( array( |
|
| 938 | + $defaults = shortcode_atts(array( |
|
| 939 | 939 | 'id' => '', |
| 940 | 940 | 'sku' => '', |
| 941 | 941 | 'total' => false |
| 942 | - ), $atts ); |
|
| 942 | + ), $atts); |
|
| 943 | 943 | |
| 944 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 944 | + $atts = wp_parse_args($atts, $defaults); |
|
| 945 | 945 | |
| 946 | - if ( ! empty( $atts['id'] ) && $atts['id'] > 0 ) { |
|
| 947 | - $product_data = wc_get_product( $atts['id'] ); |
|
| 948 | - } elseif ( ! empty( $atts['sku'] ) ) { |
|
| 949 | - $product_id = wc_get_product_id_by_sku( $atts['sku'] ); |
|
| 950 | - $product_data = get_post( $product_id ); |
|
| 946 | + if ( ! empty($atts[ 'id' ]) && $atts[ 'id' ] > 0) { |
|
| 947 | + $product_data = wc_get_product($atts[ 'id' ]); |
|
| 948 | + } elseif ( ! empty($atts[ 'sku' ])) { |
|
| 949 | + $product_id = wc_get_product_id_by_sku($atts[ 'sku' ]); |
|
| 950 | + $product_data = get_post($product_id); |
|
| 951 | 951 | } else { |
| 952 | - $product_data = wc_get_product( $post->ID ); |
|
| 952 | + $product_data = wc_get_product($post->ID); |
|
| 953 | 953 | } |
| 954 | 954 | |
| 955 | 955 | // Check that the product type is supported. Return blank if not supported. |
| 956 | - if ( ! is_object( $product_data ) || ! in_array( $product_data->product_type, self::get_supported_product_types() ) ) { |
|
| 956 | + if ( ! is_object($product_data) || ! in_array($product_data->product_type, self::get_supported_product_types())) { |
|
| 957 | 957 | return ''; |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | ob_start(); |
| 961 | 961 | |
| 962 | 962 | // Subscription Active Price |
| 963 | - $initial_payment = self::get_subscription_price_meta( array( 'id' => $product_data->id, 'meta' => 'active' ) ); |
|
| 963 | + $initial_payment = self::get_subscription_price_meta(array('id' => $product_data->id, 'meta' => 'active')); |
|
| 964 | 964 | |
| 965 | 965 | // Free Trial ? |
| 966 | - $trial_length = self::get_subscription_trial_length( array( 'id' => $product_data->id ) ); |
|
| 966 | + $trial_length = self::get_subscription_trial_length(array('id' => $product_data->id)); |
|
| 967 | 967 | |
| 968 | 968 | // If there is a free trial then the initial payment is Zero. |
| 969 | - if ( $trial_length > 0 ) { |
|
| 969 | + if ($trial_length > 0) { |
|
| 970 | 970 | $initial_payment = 0; |
| 971 | 971 | } |
| 972 | 972 | |
| 973 | 973 | // Sign up fee ? |
| 974 | - $sign_up_fee = self::get_subscription_sign_up_fee( array( 'id' => $product_data->id, 'raw' => true ) ); |
|
| 974 | + $sign_up_fee = self::get_subscription_sign_up_fee(array('id' => $product_data->id, 'raw' => true)); |
|
| 975 | 975 | |
| 976 | 976 | // Apply the sign up fee if it exists. |
| 977 | - if ( !empty( $sign_up_fee ) && $sign_up_fee > 0 ) { |
|
| 977 | + if ( ! empty($sign_up_fee) && $sign_up_fee > 0) { |
|
| 978 | 978 | |
| 979 | - if ( ! $atts['total'] ) { |
|
| 980 | - $initial_payment = sprintf( __( '%s with a %s sign up fee.', WCSS::TEXT_DOMAIN ), wc_price( $initial_payment ), wc_price( $sign_up_fee ) ); |
|
| 979 | + if ( ! $atts[ 'total' ]) { |
|
| 980 | + $initial_payment = sprintf(__('%s with a %s sign up fee.', WCSS::TEXT_DOMAIN), wc_price($initial_payment), wc_price($sign_up_fee)); |
|
| 981 | 981 | } else { |
| 982 | - $initial_payment = round( ( double ) $initial_payment+$sign_up_fee, wc_get_price_decimals() ); |
|
| 982 | + $initial_payment = round((double) $initial_payment + $sign_up_fee, wc_get_price_decimals()); |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | // Convert number into a price tag. |
| 988 | - if ( is_numeric( $initial_payment ) ) { |
|
| 989 | - $initial_payment = wc_price( $initial_payment ); |
|
| 988 | + if (is_numeric($initial_payment)) { |
|
| 989 | + $initial_payment = wc_price($initial_payment); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | // Clean the price tag. |
| 993 | - $initial_payment = self::clean_wc_price( $initial_payment ); |
|
| 993 | + $initial_payment = self::clean_wc_price($initial_payment); |
|
| 994 | 994 | |
| 995 | 995 | echo $initial_payment; |
| 996 | 996 | |
@@ -1003,11 +1003,11 @@ discard block |
||
| 1003 | 1003 | * @param $product_types |
| 1004 | 1004 | * @return array |
| 1005 | 1005 | */ |
| 1006 | - public static function support_product_types_for_wc_satt( $product_types ) { |
|
| 1006 | + public static function support_product_types_for_wc_satt($product_types) { |
|
| 1007 | 1007 | // Only add the product types from the WooCommerce extension "Subscribe to All the Things" if it is active. |
| 1008 | - if ( class_exists( 'WCS_ATT' ) ) { |
|
| 1008 | + if (class_exists('WCS_ATT')) { |
|
| 1009 | 1009 | $satt_product_types = WCS_ATT()->get_supported_product_types(); |
| 1010 | - $product_types = array_merge( $satt_product_types, $product_types ); |
|
| 1010 | + $product_types = array_merge($satt_product_types, $product_types); |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | return $product_types; |
@@ -1021,10 +1021,10 @@ discard block |
||
| 1021 | 1021 | * @global $woocommerce |
| 1022 | 1022 | * @return string |
| 1023 | 1023 | */ |
| 1024 | - public static function clean_wc_price( $price ) { |
|
| 1024 | + public static function clean_wc_price($price) { |
|
| 1025 | 1025 | global $woocommerce; |
| 1026 | 1026 | |
| 1027 | - if ( version_compare( $woocommerce->version, '2.6.0' ) >= 0 ) { |
|
| 1027 | + if (version_compare($woocommerce->version, '2.6.0') >= 0) { |
|
| 1028 | 1028 | |
| 1029 | 1029 | $find = array( |
| 1030 | 1030 | '<span class="woocommerce-Price-amount amount">', |
@@ -1032,8 +1032,8 @@ discard block |
||
| 1032 | 1032 | '</span>' |
| 1033 | 1033 | ); |
| 1034 | 1034 | |
| 1035 | - foreach( $find as $remove ) { |
|
| 1036 | - $price = str_replace( $remove, '', $price ); |
|
| 1035 | + foreach ($find as $remove) { |
|
| 1036 | + $price = str_replace($remove, '', $price); |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | } |