PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Modules / MultiStep.php
shop-press / Modules Last commit date
VariationSwatches 1 week ago Wishlist 1 week ago AdminMessage.php 1 week ago AjaxSearch.php 1 week ago Backorder.php 1 week ago CatalogMode.php 1 year ago Compare.php 1 week ago DefaultTemplates.php 2 years ago FlashSalesCountdown.php 1 year ago MenuCart.php 4 months ago MobilePanel.php 1 week ago MultiStep.php 1 year ago Notifications.php 1 week ago QuickView.php 1 week ago RecentlyViewedProducts.php 1 year ago RenameLabel.php 4 months ago Shopify.php 1 year ago SingleAjaxAddToCart.php 1 week ago SizeChart.php 1 week ago StickyAddToCart.php 1 week ago
MultiStep.php
100 lines
1 <?php
2 /**
3 * Multi step checkout.
4 *
5 * @package ShopPress
6 */
7
8 namespace ShopPress\Modules;
9
10 defined( 'ABSPATH' ) || exit;
11
12 class MultiStep {
13 /**
14 * Init.
15 *
16 * @since 1.2.0
17 */
18 public static function init() {
19
20 if ( ! sp_get_module_settings( 'multi_step_checkout', 'status' ) ) {
21 return;
22 }
23 remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
24 remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
25 remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
26 remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
27 remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
28 add_action( 'sp-woocommerce_order_review', 'woocommerce_order_review', 20 );
29 add_action( 'sp-woocommerce_checkout_payment', 'woocommerce_checkout_payment', 10 );
30 add_action( 'sp-woocommerce_checkout_login_form', 'woocommerce_checkout_login_form', 10 );
31 add_action( 'sp-woocommerce_checkout_coupon_form', 'woocommerce_checkout_coupon_form', 10 );
32 add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ), 99 );
33 add_filter( 'wc_get_template', array( __CLASS__, 'wc_custom_templates' ), 30, 3 );
34 add_filter( 'woocommerce_checkout_fields', array( __CLASS__, 'filter_checkout_fields' ), 9999 );
35 }
36
37 /**
38 * Load WC custom templates.
39 *
40 * @since 1.0.0
41 */
42 public static function wc_custom_templates( $located, $template_name ) {
43
44 if ( 'checkout/form-checkout.php' === $template_name ) {
45 $located = sp_get_template_path( 'checkout/multi-step-checkout-form' );
46 }
47
48 return $located;
49 }
50
51 /**
52 * enqueue scripts.
53 *
54 * @since 1.0.0
55 */
56 public static function enqueue_scripts() {
57
58 if ( is_checkout() ) {
59
60 wp_enqueue_script( 'sp-multi-step-checkout' );
61 wp_enqueue_style( 'sp-multi-step-checkout' );
62
63 if ( is_rtl() ) {
64 wp_enqueue_style( 'sp-multi-step-checkout-rtl' );
65 }
66
67 wp_enqueue_style( 'sp-checkout' );
68
69 if ( is_rtl() ) {
70 wp_enqueue_style( 'sp-checkout-rtl' );
71 }
72 }
73 }
74
75 /**
76 * Filter checkout fields.
77 *
78 * @param array $fields
79 *
80 * @since 1.3.7
81 */
82 public static function filter_checkout_fields( $fields ) {
83
84 $remove_billing_address_2 = sp_get_module_settings( 'multi_step_checkout', 'remove_billing_address_2' );
85 $remove_shipping_address_2 = sp_get_module_settings( 'multi_step_checkout', 'remove_shipping_address_2' );
86
87 if ( $remove_billing_address_2 ) {
88
89 unset( $fields['billing']['billing_address_2'] );
90 }
91
92 if ( $remove_shipping_address_2 ) {
93
94 unset( $fields['shipping']['shipping_address_2'] );
95 }
96
97 return $fields;
98 }
99 }
100