PluginProbe ʕ •ᴥ•ʔ
PiWeb Product Enquiry or product catalog for WooCommerce / 2.2.33.49
PiWeb Product Enquiry or product catalog for WooCommerce v2.2.33.49
2.2.34.43 2.2.34.42 2.2.34.41 2.2.34.40 2.2.34.39 trunk 2.2.22 2.2.26 2.2.33.16 2.2.33.17 2.2.33.19 2.2.33.20 2.2.33.21 2.2.33.22 2.2.33.23 2.2.33.24 2.2.33.26 2.2.33.27 2.2.33.29 2.2.33.30 2.2.33.31 2.2.33.32 2.2.33.33 2.2.33.34 2.2.33.36 2.2.33.37 2.2.33.39 2.2.33.40 2.2.33.41 2.2.33.42 2.2.33.43 2.2.33.44 2.2.33.46 2.2.33.47 2.2.33.49 2.2.34.0 2.2.34.1 2.2.34.10 2.2.34.11 2.2.34.12 2.2.34.13 2.2.34.14 2.2.34.16 2.2.34.17 2.2.34.19 2.2.34.2 2.2.34.20 2.2.34.21 2.2.34.22 2.2.34.23 2.2.34.24 2.2.34.26 2.2.34.27 2.2.34.29 2.2.34.3 2.2.34.30 2.2.34.31 2.2.34.32 2.2.34.33 2.2.34.34 2.2.34.36 2.2.34.37 2.2.34.4 2.2.34.6 2.2.34.7 2.2.34.9
enquiry-quotation-for-woocommerce / public / class-eqw-product.php
enquiry-quotation-for-woocommerce / public Last commit date
css 1 year ago img 1 year ago js 1 year ago partials 1 year ago class-email.php 1 year ago class-eqw-advance.php 1 year ago class-eqw-enquiry-cart.php 1 year ago class-eqw-enquiry-shortcode.php 1 year ago class-eqw-product.php 1 year ago class-eqw-save-enquiry.php 1 year ago class-pisol-enquiry-quotation-woocommerce-public.php 1 year ago class-pisol-form.php 1 year ago class-webhook.php 1 year ago index.php 1 year ago
class-eqw-product.php
187 lines
1 <?php
2
3 class class_eqw_product{
4
5 public $single_product_enquiry_position;
6 public $loop_product_enquiry_position;
7 public $add_to_enquiry_text_loop;
8 public $add_to_enquiry_text_single;
9 public $trouble_shoot_position;
10
11
12 function __construct(){
13
14 /**
15 * https://businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/
16 */
17 $this->single_product_enquiry_position = 52;
18
19 $this->loop_product_enquiry_position = 'woocommerce_after_shop_loop_item';
20
21 $this->add_to_enquiry_text_loop = get_option('pi_eqw_enquiry_loop_button_text','Add to Enquiry');
22 $this->add_to_enquiry_text_single = get_option('pi_eqw_enquiry_single_button_text','Add to Enquiry');
23
24 $this->trouble_shoot_position = get_option('pi_eqw_trouble_shoot_position',0);
25
26 if($this->trouble_shoot_position){
27 add_action( 'woocommerce_single_product_summary', array($this,'add_enquiry_button'), $this->single_product_enquiry_position);
28 }else{
29 add_action( 'woocommerce_after_template_part', array($this,'add_enquiry_button_new'), 10,1);
30 }
31
32 add_action($this->loop_product_enquiry_position, array($this,'add_loop_enquiry_button'), 50 );
33
34 }
35
36 static function styleProductPage(){
37 $button_width_single = get_option('pisol_eqw_button_size', '200');
38 $button_font_single = get_option('pisol_eqw_button_font_size', '16');
39
40 if(!empty($button_width_single)){
41 $width = " width:{$button_width_single}px; ";
42 }else{
43 $width = '';
44 }
45
46
47 if(!empty($button_font_single)){
48 $font = " font-size:{$button_font_single}px; ";
49 }else{
50 $font = '';
51 }
52
53 $style = $width.$font;
54 return $style;
55 }
56
57 static function styleLoopPage(){
58 $button_width_loop = get_option('pisol_eqw_loop_button_size', '');
59 $button_font_loop = get_option('pisol_eqw_loop_button_font_size', '16');
60
61 if(!empty($button_width_loop)){
62 $width = " width:{$button_width_loop}px; ";
63 }else{
64 $width = '';
65 }
66
67
68 if(!empty($button_font_loop)){
69 $font = " font-size:{$button_font_loop}px; ";
70 }else{
71 $font = '';
72 }
73
74 $style = $width.$font;
75 return $style;
76 }
77
78 /**
79 * remove this after few releases as this is old way of adding
80 * button
81 */
82 function add_enquiry_button(){
83 global $product;
84
85 if(!$this->showButtonOnSinglePage($product)) return;
86
87 $style = self::styleProductPage();
88
89 if($product->is_type('variable') ){
90 echo '<button class="button pi-custom-button add-to-enquiry add-to-enquiry-single" href="javascript:void(0)" data-action="pi_add_to_enquiry" data-id="'.esc_attr($product->get_id()).'" style="'.esc_attr( $style ).'">' . esc_html($this->add_to_enquiry_text_single). '</button>';
91 }else{
92 echo '<button class="button pi-custom-button add-to-enquiry add-to-enquiry-single" href="javascript:void(0)" data-action="pi_add_to_enquiry" data-id="'.esc_attr($product->get_id()).'" style="'.esc_attr( $style ).'">' . esc_html($this->add_to_enquiry_text_single). '</button>';
93 }
94 }
95
96 function add_enquiry_button_new($tmp_name){
97
98 if(in_array($tmp_name, array('single-product/add-to-cart/simple.php'))){
99 global $product;
100 if(is_object($product)){
101 if(!$this->showButtonOnSinglePage($product)) return;
102
103 $style = self::styleProductPage();
104
105 if($product->is_type('variable') ){
106 echo '<button class="button pi-custom-button add-to-enquiry add-to-enquiry-single" href="javascript:void(0)" data-action="pi_add_to_enquiry" data-id="'.esc_attr( $product->get_id() ).'" style="'.esc_attr( $style ).'">' . esc_html($this->add_to_enquiry_text_single). '</button>';
107 }else{
108 echo '<button class="button pi-custom-button add-to-enquiry add-to-enquiry-single" href="javascript:void(0)" data-action="pi_add_to_enquiry" data-id="'.esc_attr( $product->get_id() ).'" style="'.esc_attr( $style ).'">' . esc_html($this->add_to_enquiry_text_single). '</button>';
109 }
110 }
111 }
112 }
113
114 function add_loop_enquiry_button() {
115 global $product;
116
117 if(!$this->showButtonOnLoopPage($product)) return;
118
119 $style = self::styleLoopPage();
120
121 if($product->is_type('variable') ){
122 echo '<div style="margin-bottom:10px; text-align:center; width:100%;">
123 <a class="button pi-custom-button add-to-enquiry-loop" href="'.esc_url( $product->get_permalink() ).'" style="'.esc_attr( $style ).'">'.esc_html($this->add_to_enquiry_text_loop).'</a>
124 </div>';
125 }else{
126 echo '<div style="margin-bottom:10px; text-align:center; width:100%;">
127 <a class="button pi-custom-button add-to-enquiry add-to-enquiry-loop" href="javascript:void(0)" data-action="pi_add_to_enquiry" data-id="'.esc_attr( $product->get_id() ).'" style="'.esc_attr( $style ).'">'.esc_html($this->add_to_enquiry_text_loop).'</a>
128 </div>';
129 }
130 }
131
132 function showButtonOnLoopPage($product){
133 if( $product->is_type('grouped') || $product->is_type('variable') ) return false;
134
135
136 /**
137 * this show enquiry if product is out of stock and you want to show when product is out of stock
138 */
139 /*
140 $pi_eqw_loop_show_on_out_of_stock = get_option('pi_eqw_loop_show_on_out_of_stock', 0);
141 if($pi_eqw_loop_show_on_out_of_stock == 1){
142 if(!$product->is_in_stock()){
143 return true;
144 }
145 }
146 */
147 /**
148 * global loop is off,
149 * but still you can enable it for single product from product overwrite
150 * enable it for out of stocks
151 */
152 $pi_eqw_enquiry_loop = get_option('pi_eqw_enquiry_loop',0);
153 if($pi_eqw_enquiry_loop != 1) return false;
154
155 return true;
156 }
157
158 function showButtonOnSinglePage($product){
159 if( $product->is_type('grouped') || $product->is_type('variable')) return false;
160
161
162 /**
163 * this show enquiry if product is out of stock and you want to show when product is out of stock
164 */
165 /*
166 $pi_eqw_single_show_on_out_of_stock = get_option('pi_eqw_single_show_on_out_of_stock', 0);
167 if($pi_eqw_single_show_on_out_of_stock == 1){
168 if(!$product->is_in_stock()){
169 return true;
170 }
171 }
172 */
173 /**
174 * global single is off,
175 * but still you can enable it for single product from product overwrite
176 * enable it for out of stocks
177 */
178 $pi_eqw_enquiry_single = get_option('pi_eqw_enquiry_single',1);
179 if($pi_eqw_enquiry_single != 1) return false;
180
181 return true;
182 }
183 }
184
185 new class_eqw_product();
186
187