PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Modules / ShopifyCheckout / ShopifyCheckoutFns.php

ShopifyCheckoutFns.php in ShopBuilder – WooCommerce Builder For Elementor 3.2.6, at app/Modules/ShopifyCheckout/ShopifyCheckoutFns.php

152 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Sticky add-to-cart Functions Class.
4 *
5 * @package Rse\SB
6 */
7
8 namespace RadiusTheme\SB\Modules\ShopifyCheckout;
9
10 use RadiusTheme\SB\Helpers\Fns;
11 use function WooCommerce\PayPalCommerce\OrderTracking\tr;
12
13 defined( 'ABSPATH' ) || exit();
14
15 /**
16 * Sticky add-to-cart Functions Class.
17 */
18 class ShopifyCheckoutFns {
19
20 /**
21 * Is Multistep
22 *
23 * @return string
24 */
25 public static function is_maltistep() {
26 global $shopify_checkout_options;
27 return rtsb()->has_pro() && 'on' === ( $shopify_checkout_options['enable_multi_step'] ?? 'off' );
28 }
29 /**
30 * Is Clickable
31 *
32 * @return bool
33 */
34 public static function is_review_item_clickble() {
35 global $shopify_checkout_options;
36 return 'on' === ( $shopify_checkout_options['order_review_item_link'] ?? 'off' );
37 }
38
39
40 /**
41 * Generates HTML markup for displaying an endpoint icon.
42 *
43 * @return string
44 */
45 public static function print_text_setting( $field_key, $default = '' ) {
46 global $shopify_checkout_options;
47 $text = do_shortcode( $shopify_checkout_options[ $field_key ] ?? $default );
48 if ( empty( $text ) ) {
49 return;
50 }
51 $text = str_replace( '{year}', gmdate( 'Y' ), $text );
52 Fns::print_html( $text );
53 }
54
55 /**
56 * Generates HTML markup for displaying an endpoint icon.
57 *
58 * @return string
59 */
60 public static function print_footer_menu() {
61 global $shopify_checkout_options;
62 $menu_slug = $shopify_checkout_options['footer_menu'] ?? false;
63 if ( ! $menu_slug ) {
64 return;
65 }
66 // Get the menu object by slug.
67 $menu = wp_get_nav_menu_object( $menu_slug );
68 if ( ! $menu ) {
69 return;
70 }
71 // Get menu items by menu ID.
72 $menu_items = wp_get_nav_menu_items( $menu->term_id );
73 if ( empty( $menu_items ) ) {
74 return;
75 }
76 $menu_html = '<ul class="shopify-footer-menu rtsb-d-flex">';
77 foreach ( $menu_items as $item ) {
78 $menu_html .= "<li><a href='{$item->url}'>{$item->title}</a></li>";
79 }
80 $menu_html .= '</ul>';
81 Fns::print_html( $menu_html, true );
82 }
83
84 /**
85 * Generates HTML markup for displaying an endpoint icon.
86 *
87 * @return string
88 */
89 public static function get_shopify_page_logo( $isReturn = false ) {
90 global $shopify_checkout_options;
91 $cart_image_icon = ! empty( $shopify_checkout_options['shopify_page_logo'] ) ? json_decode( stripslashes( $shopify_checkout_options['shopify_page_logo'] ), true ) : false;
92 if ( empty( $cart_image_icon ) ) {
93 return;
94 }
95 $style = '';
96 if ( ! empty( $shopify_checkout_options['shopify_logo_height'] ) ) {
97 $style .= 'height:' . $shopify_checkout_options['shopify_logo_height'] . 'px;';
98 }
99 $icon_id = $cart_image_icon['id'] ?? 0;
100
101 if ( ! wp_attachment_is_image( $icon_id ) ) {
102 return;
103 }
104 $html = '<div class="rtsb-shopify-logo" style="' . esc_attr( $style ) . '" >';
105 $html .= wp_get_attachment_image( absint( $icon_id ), 'full' );
106
107 $html .= '</div>';
108 if ( $isReturn ) {
109 return $html;
110 }
111 Fns::print_html( $html );
112 }
113 /**
114 * Generates HTML markup for displaying an endpoint icon.
115 *
116 * @return string
117 */
118 public static function get_cart_icon_html( $isReturn = false ) {
119 $data = [];
120 $html = '';
121 global $shopify_checkout_options;
122 if ( 'none' === ( $shopify_checkout_options['cart_icon_source'] ?? '' ) ) {
123 $data['icon_source'] = 'none';
124 } elseif ( 'select_icon' === ( $shopify_checkout_options['cart_icon_source'] ?? '' ) ) {
125 $data['icon_source'] = 'select_icon';
126 $data['custom_icon'] = ( $shopify_checkout_options['cart_icon'] ?? '' );
127 } elseif ( 'upload_icon' === ( $shopify_checkout_options['cart_icon_source'] ?? '' ) ) {
128 $data['icon_source'] = 'upload_icon';
129 $cart_image_icon = ! empty( $shopify_checkout_options['cart_image_icon'] ) ? json_decode( stripslashes( $shopify_checkout_options['cart_image_icon'] ), true ) : false;
130 if ( ! empty( $cart_image_icon['id'] ) && ! empty( $cart_image_icon['source'] ) ) {
131 $data['image_icon'] = [
132 'id' => $cart_image_icon['id'],
133 'source' => $cart_image_icon['source'],
134 ];
135 }
136 } else {
137 $html = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" focusable="false" aria-hidden="true" class="rtsb-shopify-header-cart-icon">
138 <path d="M2.675 10.037 3.072 4.2h7.856l.397 5.837A2.4 2.4 0 0 1 8.932 12.6H5.069a2.4 2.4 0 0 1-2.394-2.563"></path>
139 <path d="M4.9 3.5a2.1 2.1 0 1 1 4.2 0v1.4a2.1 2.1 0 0 1-4.2 0z"></path>
140 </svg>';
141 }
142 if ( empty( $data ) ) {
143 return $html;
144 }
145 $html = Fns::get_icon_html( $data, false );
146 if ( $isReturn ) {
147 return $html;
148 }
149 Fns::print_html( $html, true );
150 }
151 }
152