PluginProbe ʕ •ᴥ•ʔ
PiWeb Product Enquiry or product catalog for WooCommerce / 2.2.33.21
PiWeb Product Enquiry or product catalog for WooCommerce v2.2.33.21
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-enquiry-shortcode.php
enquiry-quotation-for-woocommerce / public Last commit date
css 2 years ago img 2 years ago js 2 years ago partials 2 years ago class-email.php 2 years ago class-eqw-advance.php 2 years ago class-eqw-enquiry-cart.php 2 years ago class-eqw-enquiry-shortcode.php 2 years ago class-eqw-product.php 2 years ago class-eqw-save-enquiry.php 2 years ago class-pisol-enquiry-quotation-woocommerce-public.php 2 years ago class-pisol-form.php 2 years ago class-webhook.php 2 years ago index.php 2 years ago
class-eqw-enquiry-shortcode.php
94 lines
1 <?php
2
3 class class_eqw_enquiry_shortcode{
4
5 public $products;
6
7 function __construct(){
8
9 add_shortcode('pisol_enquiry_cart',array($this, 'enquiry_cart_template'));
10 /** this shortcode [enquiry_cart] is to support old sites */
11 add_shortcode('enquiry_cart',array($this, 'enquiry_cart_template'));
12 add_action('wp_ajax_get_cart_on_load', array($this,'cartOnFirstLoad'));
13 add_action('wp_ajax_nopriv_get_cart_on_load', array($this,'cartOnFirstLoad'));
14 }
15
16 function enquiry_cart_template(){
17 ob_start();
18 $this->products = class_eqw_enquiry_cart::getProductsInEnquirySession();
19 include('partials/pisol-eqw-shortcode.php');
20 $ret = ob_get_contents();
21 ob_end_clean();
22 return $ret;
23 }
24
25 function cartOnFirstLoad(){
26 $this->products = class_eqw_enquiry_cart::getProductsInEnquirySession();
27 ob_start();
28 pisol_table_row($this->products);
29 $cart = ob_get_contents(); // read ob2 ("b")
30 ob_end_clean();
31 $data = array(
32 'cart'=> $cart,
33 'pisol_products'=> class_eqw_enquiry_cart::filter_message($this->products)
34 );
35 echo json_encode($data, JSON_UNESCAPED_SLASHES);
36 die;
37 }
38
39 static function get_price($product) {
40 if( $product->is_on_sale() ) {
41 return $product->get_sale_price();
42 }
43 return $product->get_regular_price();
44 }
45
46 static function get_price_simple_variation($product, $variation_id){
47 if ($product->is_type( 'simple' )) {
48 return self::get_price($product);
49 }elseif($product->is_type('variable')){
50 $variation_product = new WC_Product_Variation( $variation_id );
51 return self::get_price($variation_product);
52 }
53 }
54
55 static function get_variations($product, $variations_detail, $echo = false){
56 // test if product is variable
57 if($variations_detail == null || $variations_detail == "" || $variations_detail == false){
58 return ;
59 }
60
61 $variations = "";
62 $variations_label = array();
63 if( $product->is_type( 'variable' ) ){
64 // Loop through available product variation data
65 foreach ( $variations_detail as $attribute => $term_slug ) {
66 // Loop through the product attributes for this variation
67 $taxonomy = str_replace( 'attribute_', '', $attribute );
68 $attr_label_name = wc_attribute_label( $taxonomy );
69
70 $term_obj = get_term_by( 'slug', $term_slug, $taxonomy );
71 $term_name = is_object($term_obj) ? $term_obj->name : $term_slug;
72 $variations_label[$attr_label_name] = $term_name;
73
74 }
75 }
76 if($echo){
77 self::variation_html($variations_label);
78 }else{
79 return $variations_label;
80 }
81 }
82
83 static function variation_html($variations_label){
84 if(is_array($variations_label)){
85 echo '<br>';
86 foreach ($variations_label as $key => $value){
87 echo '<strong class="pi-attribute-label">'.$key.'</strong> : <span>'.$value.'</span><br>';
88 }
89 }
90 }
91
92 }
93
94 new class_eqw_enquiry_shortcode();