PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.2
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
← All changes | inc/modules/checkout/class-checkout.php +156 -146 1.82.3.2 View file →
@@ -1,146 +1,156 @@
1 -<?php
2 -
3 -/**
4 - * Checkout
5 - *
6 - * @package Merchant
7 - */
8 -
9 -if ( ! defined( 'ABSPATH' ) ) {
10 - exit; // Exit if accessed directly
11 -}
12 -
13 -/**
14 - * Checkout class.
15 - *
16 - */
17 -class Merchant_Checkout extends Merchant_Add_Module {
18 -
19 - /**
20 - * Module ID.
21 - *
22 - */
23 - const MODULE_ID = 'checkout';
24 -
25 - /**
26 - * Is module preview.
27 - *
28 - */
29 - public static $is_module_preview = false;
30 -
31 - /**
32 - * Constructor.
33 - *
34 - */
35 - public function __construct() {
36 -
37 - // Module id.
38 - $this->module_id = self::MODULE_ID;
39 -
40 - // WooCommerce only.
41 - $this->wc_only = true;
42 -
43 - // Parent construct.
44 - parent::__construct();
45 -
46 - // Module section.
47 - $this->module_section = 'convert-more';
48 -
49 - // Module default settings.
50 - $this->module_default_settings = array(
51 - 'layout' => 'layout-shopify',
52 - 'sticky_totals_box' => 0
53 - );
54 -
55 - // Mount preview url.
56 - $preview_url = site_url( '/' );
57 -
58 - if ( function_exists( 'wc_get_page_id' ) ) {
59 - $preview_url = get_permalink( wc_get_page_id( 'checkout' ) );
60 - }
61 -
62 - // Module data.
63 - $this->module_data = Merchant_Admin_Modules::$modules_data[ self::MODULE_ID ];
64 - $this->module_data[ 'preview_url' ] = $preview_url;
65 -
66 - // Module options path.
67 - $this->module_options_path = MERCHANT_DIR . 'inc/modules/' . self::MODULE_ID . '/admin/options.php';
68 -
69 - // Is module preview page.
70 - if ( is_admin() && parent::is_module_settings_page() ) {
71 - self::$is_module_preview = true;
72 -
73 - // Enqueue admin styles.
74 - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_css' ) );
75 -
76 - // Admin preview box.
77 - add_filter( 'merchant_module_preview', array( $this, 'render_admin_preview' ), 10, 2 );
78 -
79 - }
80 - }
81 -
82 - /**
83 - * Admin enqueue CSS.
84 - *
85 - * @return void
86 - */
87 - public function admin_enqueue_css() {
88 - $page = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
89 - $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
90 -
91 - if ( 'merchant' === $page && self::MODULE_ID === $module ) {
92 - wp_enqueue_style( 'merchant-admin-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/admin/preview.min.css', array(), MERCHANT_VERSION );
93 - }
94 - }
95 -
96 - /**
97 - * Render admin preview
98 - *
99 - * @param Merchant_Admin_Preview $preview
100 - * @param string $module
101 - *
102 - * @return Merchant_Admin_Preview
103 - */
104 - public function render_admin_preview( $preview, $module ) {
105 - if ( self::MODULE_ID === $module ) {
106 - ob_start();
107 - $this->checkout_admin_preview_output();
108 - $content = ob_get_clean();
109 -
110 - // HTML.
111 - $preview->set_html( $content );
112 -
113 - // Toggle layout class identifier.
114 - $preview->set_class( 'layout', '.mrc-checkout-preview', array( 'layout-shopify', 'layout-one-step', 'layout-multi-step' ) );
115 -
116 - }
117 -
118 - return $preview;
119 - }
120 -
121 - public function checkout_admin_preview_output() {
122 - $settings = $this->get_module_settings();
123 -
124 - ?>
125 -
126 - <div class="mrc-checkout-preview <?php echo esc_attr( $settings[ 'layout' ] ); ?>">
127 - <div class="mrc-checkout-preview-one-step">
128 - <img src="<?php echo esc_url( MERCHANT_URI . 'inc/modules/checkout/admin/images/preview-layout-one-step.png' ); ?>" />
129 - </div>
130 - <div class="mrc-checkout-preview-shopify">
131 - <img src="<?php echo esc_url( MERCHANT_URI . 'inc/modules/checkout/admin/images/preview-layout-shopify.png' ); ?>" />
132 - </div>
133 - <div class="mrc-checkout-preview-multi-step">
134 - <img src="<?php echo esc_url( MERCHANT_URI . 'inc/modules/checkout/admin/images/preview-layout-multi-step.png' ); ?>" />
135 - </div>
136 - </div>
137 -
138 - <?php
139 - }
140 -
141 -}
142 -
143 -// Initialize the module.
144 -add_action( 'init', function () {
145 - Merchant_Modules::create_module( new Merchant_Checkout() );
146 -} );
1 +<?php
2 +
3 +/**
4 + * Checkout
5 + *
6 + * @package Merchant
7 + */
8 +
9 +if ( ! defined( 'ABSPATH' ) ) {
10 + exit; // Exit if accessed directly
11 +}
12 +
13 +/**
14 + * Checkout class.
15 + *
16 + */
17 +class Merchant_Checkout extends Merchant_Add_Module {
18 +
19 + /**
20 + * Module ID.
21 + *
22 + */
23 + const MODULE_ID = 'checkout';
24 +
25 + /**
26 + * Is module preview.
27 + *
28 + */
29 + public static $is_module_preview = false;
30 +
31 + /**
32 + * Initialize the module's option group definitions.
33 + *
34 + * @return array<int, array<string, mixed>> Array of option group arrays.
35 + */
36 + protected function init_option_groups() {
37 + return require MERCHANT_DIR . 'inc/modules/' . self::MODULE_ID . '/admin/options.php';
38 + }
39 +
40 + /**
41 + * Constructor.
42 + *
43 + */
44 + public function __construct() {
45 +
46 + // Module id.
47 + $this->module_id = self::MODULE_ID;
48 +
49 + // WooCommerce only.
50 + $this->wc_only = true;
51 +
52 + // Parent construct.
53 + parent::__construct();
54 +
55 + // Module section.
56 + $this->module_section = 'convert-more';
57 +
58 + // Module default settings.
59 + $this->module_default_settings = array(
60 + 'layout' => 'layout-shopify',
61 + 'sticky_totals_box' => 0,
62 + );
63 +
64 + // Module data.
65 + $this->module_data = Merchant_Admin_Modules::$modules_data[ self::MODULE_ID ];
66 +
67 + // AI prompt examples.
68 + $this->ai_examples = array(
69 + 'blurb' => esc_html__( 'See what AI can do for your checkout, from switching between the Shopify-style, one-step, and multi-step layouts to keeping the order totals box sticky as shoppers scroll.', 'merchant' ),
70 + 'prompts' => array(
71 + esc_html__( 'Explore the abilities WPVibe gives you access to, then switch my checkout to the one-step layout', 'merchant' ),
72 + esc_html__( 'Check what abilities you have available through WPVibe, then change the checkout to the multi-step layout instead', 'merchant' ),
73 + esc_html__( 'Look at your available WPVibe abilities, then switch to the Shopify-style layout and keep the order totals box sticky as shoppers scroll', 'merchant' ),
74 + ),
75 + );
76 +
77 + // Module options path.
78 + $this->module_options_path = MERCHANT_DIR . 'inc/modules/' . self::MODULE_ID . '/admin/options.php';
79 +
80 + // Is module preview page.
81 + if ( is_admin() && parent::is_module_settings_page() ) {
82 + self::$is_module_preview = true;
83 +
84 + // Enqueue admin styles.
85 + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_css' ) );
86 +
87 + // Admin preview box.
88 + add_filter( 'merchant_module_preview', array( $this, 'render_admin_preview' ), 10, 2 );
89 +
90 + }
91 + }
92 +
93 + /**
94 + * Admin enqueue CSS.
95 + *
96 + * @return void
97 + */
98 + public function admin_enqueue_css() {
99 + $page = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
100 + $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
101 +
102 + if ( 'merchant' === $page && self::MODULE_ID === $module ) {
103 + wp_enqueue_style( 'merchant-admin-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/admin/preview.min.css', array(), MERCHANT_VERSION );
104 + }
105 + }
106 +
107 + /**
108 + * Render admin preview
109 + *
110 + * @param Merchant_Admin_Preview $preview
111 + * @param string $module
112 + *
113 + * @return Merchant_Admin_Preview
114 + */
115 + public function render_admin_preview( $preview, $module ) {
116 + if ( self::MODULE_ID === $module ) {
117 + ob_start();
118 + $this->checkout_admin_preview_output();
119 + $content = ob_get_clean();
120 +
121 + // HTML.
122 + $preview->set_html( $content );
123 +
124 + // Toggle layout class identifier.
125 + $preview->set_class( 'layout', '.mrc-checkout-preview', array( 'layout-shopify', 'layout-one-step', 'layout-multi-step' ) );
126 +
127 + }
128 +
129 + return $preview;
130 + }
131 +
132 + public function checkout_admin_preview_output() {
133 + $settings = $this->get_module_settings();
134 +
135 + ?>
136 +
137 + <div class="mrc-checkout-preview <?php echo esc_attr( $settings[ 'layout' ] ); ?>">
138 + <div class="mrc-checkout-preview-one-step">
139 + <img src="<?php echo esc_url( MERCHANT_URI . 'inc/modules/checkout/admin/images/preview-layout-one-step.png' ); ?>" />
140 + </div>
141 + <div class="mrc-checkout-preview-shopify">
142 + <img src="<?php echo esc_url( MERCHANT_URI . 'inc/modules/checkout/admin/images/preview-layout-shopify.png' ); ?>" />
143 + </div>
144 + <div class="mrc-checkout-preview-multi-step">
145 + <img src="<?php echo esc_url( MERCHANT_URI . 'inc/modules/checkout/admin/images/preview-layout-multi-step.png' ); ?>" />
146 + </div>
147 + </div>
148 +
149 + <?php
150 + }
151 +}
152 +
153 +// Initialize the module.
154 +add_action( 'init', function () {
155 + Merchant_Modules::create_module( new Merchant_Checkout() );
156 +} );