css
2 years ago
js
2 years ago
class-css.php
2 years ago
class-date.php
2 years ago
class-delivery-type.php
2 years ago
class-display-field.php
2 years ago
class-js.php
2 years ago
class-main.php
2 years ago
class-order.php
2 years ago
class-pickup-location.php
2 years ago
class-shipping-method.php
2 years ago
class-time-range.php
2 years ago
class-time-slot.php
2 years ago
class-time.php
2 years ago
class-validate.php
2 years ago
class-woo-app.php
2 years ago
class-css.php
108 lines
| 1 | <?php |
| 2 | if ( ! defined( 'WPINC' ) ) { |
| 3 | die; |
| 4 | } |
| 5 | class pi_dtt_css{ |
| 6 | |
| 7 | public $plugin_name; |
| 8 | |
| 9 | function __construct(){ |
| 10 | $this->plugin_name = 'pi-woocommerce-order-date-time-and-type'; |
| 11 | |
| 12 | add_action( 'wp_enqueue_scripts', array($this,'addCss') ); |
| 13 | |
| 14 | add_action('woocommerce_thankyou', array($this,'removeSavedDateTime')); |
| 15 | |
| 16 | add_action('wp_head', array($this, 'topMarginFix'),1000); |
| 17 | } |
| 18 | |
| 19 | function addCss(){ |
| 20 | if(function_exists('is_checkout') && is_checkout()){ |
| 21 | $this->addCssFile(); |
| 22 | $this->inlineCss(); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | function cdnUrl(){ |
| 27 | $theme = 'ui-lightness'; |
| 28 | $cdn_url = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/{$theme}/jquery-ui.css"; |
| 29 | return $cdn_url; |
| 30 | } |
| 31 | |
| 32 | function addCssFile(){ |
| 33 | wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/style.css',array(), PISOL_DTT_PLUGIN_VERSION); |
| 34 | $jquery_ui = apply_filters('pisol_dtt_jquery_ui_theme',$this->cdnUrl()); |
| 35 | wp_deregister_style( 'jquery-ui' ); |
| 36 | wp_register_style( 'jquery-ui', $jquery_ui); |
| 37 | wp_enqueue_style('jquery-ui'); |
| 38 | } |
| 39 | |
| 40 | function inlineCss(){ |
| 41 | $css = ""; |
| 42 | $css .= $this->deliveryTypeButton(); |
| 43 | wp_add_inline_style( $this->plugin_name, $css); |
| 44 | } |
| 45 | |
| 46 | function deliveryTypeButton(){ |
| 47 | |
| 48 | $pi_button_bg_color = pisol_dtt_get_setting('pi_button_bg_color','#cccccc'); |
| 49 | $pi_active_button_bg_color = pisol_dtt_get_setting('pi_active_button_bg_color','#000000'); |
| 50 | $pi_button_text_color = pisol_dtt_get_setting('pi_button_text_color','#000000'); |
| 51 | $pi_active_button_text_color = pisol_dtt_get_setting('pi_active_button_text_color','#ffffff'); |
| 52 | $css = ' |
| 53 | .pi_delivery_type .woocommerce-input-wrapper label, .pi_delivery_type .woocommerce-input-wrapper .woocommerce-radio-wrapper label{ |
| 54 | background-color:'.$pi_button_bg_color.'; |
| 55 | color:'.$pi_button_text_color.'; |
| 56 | } |
| 57 | |
| 58 | .pi_delivery_type .input-radio:checked + label, |
| 59 | .pi_delivery_type .woocommerce-input-wrapper label.active_type, .pi_delivery_type .woocommerce-input-wrapper .woocommerce-radio-wrapper input:checked + label{ |
| 60 | background-color:'.$pi_active_button_bg_color.'; |
| 61 | color:'.$pi_active_button_text_color.'; |
| 62 | } |
| 63 | '; |
| 64 | return $css; |
| 65 | } |
| 66 | |
| 67 | function removeSavedDateTime($order_id){ |
| 68 | echo '<script>'; |
| 69 | echo 'jQuery(function($){ |
| 70 | |
| 71 | var fields = ["pi_system_delivery_date", "pi_delivery_time", "billing_email", "billing_first_name", "billing_last_name", "billing_phone", "billing_company", "shipping_first_name", "shipping_last_name", "shipping_company", "order_comments", "createaccount", "ship-to-different-address-checkbox"]; |
| 72 | var length = fields.length; |
| 73 | for (var i = 0; i < length; i++) { |
| 74 | var field = fields[i]; |
| 75 | var name = "pisol_"+field; |
| 76 | localStorage.removeItem(name); |
| 77 | } |
| 78 | });'; |
| 79 | echo '</script>'; |
| 80 | } |
| 81 | |
| 82 | function topMarginFix(){ |
| 83 | if(function_exists('is_admin_bar_showing') && is_admin_bar_showing() && is_checkout()){ |
| 84 | echo ' |
| 85 | <style> |
| 86 | html{ |
| 87 | margin-top:0 !important; |
| 88 | } |
| 89 | </style> |
| 90 | '; |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | add_action('wp_loaded',function(){ |
| 96 | /** |
| 97 | * This filter allow you to hide all the fields added by this plugin |
| 98 | * so you can use this to disable the plugin when you have virtual product in |
| 99 | * your cart |
| 100 | */ |
| 101 | $pisol_disable_dtt_completely = apply_filters('pisol_disable_dtt_completely',false); |
| 102 | if($pisol_disable_dtt_completely){ |
| 103 | return ; |
| 104 | } |
| 105 | |
| 106 | new pi_dtt_css(); |
| 107 | }); |
| 108 |