PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.8.1
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.8.1
4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / widgets / qr-code / qr-code.php
shopengine / widgets / qr-code Last commit date
qr-code-config.php 11 months ago qr-code.php 11 months ago
qr-code.php
124 lines
1 <?php
2
3 namespace Elementor;
4
5 defined('ABSPATH') || exit;
6
7 class ShopEngine_Qr_Code extends \ShopEngine\Base\Widget
8 {
9
10 public function config()
11 {
12 return new ShopEngine_Qr_Code_Config();
13 }
14
15 protected function register_controls()
16 {
17
18 $this->start_controls_section(
19 'shopengine-qrcode-conent',
20 [
21 'label' => __('QR Code', 'shopengine'),
22 ]
23 );
24
25 $this->add_control(
26 'shopengine_size',
27 [
28 'label' => __('Size', 'shopengine'),
29 'type' => Controls_Manager::NUMBER,
30 'min' => 0,
31 'max' => 1000,
32 'step' => 1,
33 'default' => 150,
34 ]
35 );
36
37 $this->add_control(
38 'shopengine_add_cart_url',
39 [
40 'label' => __('Scan to Add to Cart URL', 'shopengine'),
41 'description' => __('If enabled, the QR code will generate a link that adds the product to the cart when scanned.', 'shopengine'),
42 'type' => Controls_Manager::SWITCHER,
43 'return_value' => 'yes',
44 'default' => 'no',
45 ]
46 );
47
48 $this->add_control(
49 'shopengine_quantity',
50 [
51 'label' => __('Quantity', 'shopengine'),
52 'type' => Controls_Manager::NUMBER,
53 'min' => 0,
54 'max' => 500,
55 'step' => 1,
56 'default' => 1,
57 'condition' => [
58 'shopengine_add_cart_url' => 'yes',
59 ],
60 ]
61 );
62
63 $this->add_responsive_control(
64 'shopengine_code_align',
65 [
66 'label' => esc_html__('Alignment', 'shopengine'),
67 'type' => Controls_Manager::CHOOSE,
68 'options' => [
69 'left' => [
70 'title' => esc_html__('Left', 'shopengine'),
71 'icon' => 'eicon-text-align-left',
72 ],
73 'center' => [
74 'title' => esc_html__('Center', 'shopengine'),
75 'icon' => 'eicon-text-align-center',
76 ],
77 'right' => [
78 'title' => esc_html__('Right', 'shopengine'),
79 'icon' => 'eicon-text-align-right',
80 ],
81 ],
82 'selectors' => [
83 '{{WRAPPER}} .shopengine-qrcode' => 'text-align: {{VALUE}};',
84 ],
85 'separator' => 'before',
86 ]
87 );
88
89 $this->end_controls_section();
90 }
91
92 protected function screen()
93 {
94
95 $post_type = get_post_type();
96 $product = \ShopEngine\Widgets\Products::instance()->get_product($post_type);
97 $settings = $this->get_settings_for_display();
98 $product_id = $product->get_id();
99 $quantity = ( !empty($settings['shopengine_quantity'] ) ? $settings['shopengine_quantity'] : 1 );
100
101 if ($settings['shopengine_add_cart_url'] == 'yes') {
102
103 $url = get_the_permalink( $product_id) . sprintf('?add-to-cart=%s&quantity=%s', $product_id, $quantity );
104
105 } else {
106
107 $url = get_the_permalink( $product_id );
108 }
109
110 $title = get_the_title( $product_id );
111 $product_url = urlencode($url);
112 $size = ( !empty($settings['shopengine_size']) ? $settings['shopengine_size'] : 150 );
113 $size = absint( $size );
114 $dimension = esc_attr($size . 'x' . $size);
115 $image_url = sprintf( 'https://api.qrserver.com/v1/create-qr-code/?size=%s&ecc=L&qzone=1&data=%s', $dimension, $product_url);
116
117 ?>
118 <div class="shopengine-qrcode">
119 <img src="<?php echo esc_url( $image_url ) ?>" alt="<?php echo esc_attr( $title ); ?>">
120 </div>
121 <?php
122 }
123 }
124