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-advance.php
119 lines
| 1 | <?php |
| 2 | |
| 3 | class class_eqw_advance{ |
| 4 | |
| 5 | public $hide_price; |
| 6 | |
| 7 | function __construct(){ |
| 8 | |
| 9 | $this->hide_price = get_option('pi_eqw_hide_price','no'); // all -> hide for all, no->done hide, guest -> hide for guest visitors |
| 10 | |
| 11 | add_filter( 'woocommerce_is_purchasable', array($this,'remove_add_to_cart'), 10, 2); |
| 12 | |
| 13 | if( $this->hide_price != 'no'){ |
| 14 | |
| 15 | /** |
| 16 | * this can remove price from loop and single product page |
| 17 | */ |
| 18 | add_filter( 'woocommerce_variable_sale_price_html', array($this,'removePrice'), 10, 2 ); |
| 19 | add_filter( 'woocommerce_variable_price_html', array($this,'removePrice'), 10, 2 ); |
| 20 | add_filter( 'woocommerce_get_price_html', array($this,'removePrice'), 10, 2 ); |
| 21 | |
| 22 | } |
| 23 | |
| 24 | add_action( 'template_redirect', array($this,'redirectToEnquiryCart') ); |
| 25 | |
| 26 | } |
| 27 | |
| 28 | function remove_add_to_cart($purchasable, $product ){ |
| 29 | $pi_eqw_remove_add_to_cart = 0; |
| 30 | if($pi_eqw_remove_add_to_cart == 1 /*|| $this->hidePrice()*/){ |
| 31 | remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); |
| 32 | |
| 33 | wp_register_style( 'pisol-dummy-handle', false ); |
| 34 | wp_enqueue_style( 'pisol-dummy-handle' ); |
| 35 | |
| 36 | wp_add_inline_style( 'pisol-dummy-handle', '.single_variation_wrap, .woocommerce-variation-add-to-cart.variations_button{ |
| 37 | display:none; |
| 38 | }' ); |
| 39 | |
| 40 | return false; |
| 41 | } |
| 42 | return $purchasable; |
| 43 | } |
| 44 | |
| 45 | function removePrice( $price, $product ) { |
| 46 | if ( $this->hidePrice() ) $price = ''; |
| 47 | return $price; |
| 48 | } |
| 49 | |
| 50 | function hidePrice(){ |
| 51 | switch($this->hide_price){ |
| 52 | case 'no': |
| 53 | return false; |
| 54 | break; |
| 55 | |
| 56 | case 'all': |
| 57 | return true; |
| 58 | break; |
| 59 | |
| 60 | case 'guest': |
| 61 | if(is_user_logged_in()){ |
| 62 | return false; |
| 63 | }else{ |
| 64 | return true; |
| 65 | } |
| 66 | break; |
| 67 | } |
| 68 | |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | static function checkHidePrice(){ |
| 73 | $hide_price = get_option('pi_eqw_hide_price','no'); |
| 74 | switch($hide_price){ |
| 75 | case 'no': |
| 76 | return false; |
| 77 | break; |
| 78 | |
| 79 | case 'all': |
| 80 | return true; |
| 81 | break; |
| 82 | |
| 83 | case 'guest': |
| 84 | if(is_user_logged_in()){ |
| 85 | return false; |
| 86 | }else{ |
| 87 | return true; |
| 88 | } |
| 89 | break; |
| 90 | } |
| 91 | |
| 92 | return false; |
| 93 | } |
| 94 | |
| 95 | function redirectToEnquiryCart() { |
| 96 | $pi_eqw_redirect_to_enquiry_cart = get_option('pi_eqw_redirect_to_enquiry_cart',0); |
| 97 | |
| 98 | if($pi_eqw_redirect_to_enquiry_cart == 1){ |
| 99 | if ( is_cart() || is_checkout() ){ |
| 100 | |
| 101 | global $woocommerce; |
| 102 | // Redirect to check out url |
| 103 | $enquiry_cart = get_option('pi_eqw_enquiry_cart',""); |
| 104 | if($enquiry_cart != ""){ |
| 105 | $url = get_permalink($enquiry_cart); |
| 106 | wp_redirect( $url, '301' ); |
| 107 | exit; |
| 108 | } |
| 109 | |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | } |
| 114 | |
| 115 | } |
| 116 | |
| 117 | new class_eqw_advance(); |
| 118 | |
| 119 |