PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.2.7
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.2.7
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
merchant / inc / modules / checkout / class-checkout.php

class-checkout.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.2.7, at inc/modules/checkout/class-checkout.php

138 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 // Module data.
56 $this->module_data = Merchant_Admin_Modules::$modules_data[ self::MODULE_ID ];
57
58 // Module options path.
59 $this->module_options_path = MERCHANT_DIR . 'inc/modules/' . self::MODULE_ID . '/admin/options.php';
60
61 // Is module preview page.
62 if ( is_admin() && parent::is_module_settings_page() ) {
63 self::$is_module_preview = true;
64
65 // Enqueue admin styles.
66 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_css' ) );
67
68 // Admin preview box.
69 add_filter( 'merchant_module_preview', array( $this, 'render_admin_preview' ), 10, 2 );
70
71 }
72 }
73
74 /**
75 * Admin enqueue CSS.
76 *
77 * @return void
78 */
79 public function admin_enqueue_css() {
80 $page = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
81 $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
82
83 if ( 'merchant' === $page && self::MODULE_ID === $module ) {
84 wp_enqueue_style( 'merchant-admin-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/admin/preview.min.css', array(), MERCHANT_VERSION );
85 }
86 }
87
88 /**
89 * Render admin preview
90 *
91 * @param Merchant_Admin_Preview $preview
92 * @param string $module
93 *
94 * @return Merchant_Admin_Preview
95 */
96 public function render_admin_preview( $preview, $module ) {
97 if ( self::MODULE_ID === $module ) {
98 ob_start();
99 $this->checkout_admin_preview_output();
100 $content = ob_get_clean();
101
102 // HTML.
103 $preview->set_html( $content );
104
105 // Toggle layout class identifier.
106 $preview->set_class( 'layout', '.mrc-checkout-preview', array( 'layout-shopify', 'layout-one-step', 'layout-multi-step' ) );
107
108 }
109
110 return $preview;
111 }
112
113 public function checkout_admin_preview_output() {
114 $settings = $this->get_module_settings();
115
116 ?>
117
118 <div class="mrc-checkout-preview <?php echo esc_attr( $settings[ 'layout' ] ); ?>">
119 <div class="mrc-checkout-preview-one-step">
120 <img src="<?php echo esc_url( MERCHANT_URI . 'inc/modules/checkout/admin/images/preview-layout-one-step.png' ); ?>" />
121 </div>
122 <div class="mrc-checkout-preview-shopify">
123 <img src="<?php echo esc_url( MERCHANT_URI . 'inc/modules/checkout/admin/images/preview-layout-shopify.png' ); ?>" />
124 </div>
125 <div class="mrc-checkout-preview-multi-step">
126 <img src="<?php echo esc_url( MERCHANT_URI . 'inc/modules/checkout/admin/images/preview-layout-multi-step.png' ); ?>" />
127 </div>
128 </div>
129
130 <?php
131 }
132 }
133
134 // Initialize the module.
135 add_action( 'init', function () {
136 Merchant_Modules::create_module( new Merchant_Checkout() );
137 } );
138