Override YITH Template

User
over ride yith-woocommerce-booking-premium template in our theme
Assistant
To override a template from the **YITH WooCommerce Booking Premium** plugin in your theme, follow these steps:

### ✅ 1. **Locate the Plugin Template**
Inside the plugin directory, navigate to:

wp-content/plugins/yith-woocommerce-booking-premium/templates/

You'll find all the template files there (e.g. `single-booking.php`, `booking-form/date-picker.php`, etc.).

### ✅ 2. **Copy the Template to Your Theme**
Create a folder named `yith-woocommerce-booking` in your theme directory:

wp-content/themes/your-theme/yith-woocommerce-booking/

Now, copy the template file you want to override from the plugin into this new folder, **keeping the same folder structure**.

> For example, to override:

wp-content/plugins/yith-woocommerce-booking-premium/templates/booking-form/date-picker.php

You should place it in:

wp-content/themes/your-theme/yith-woocommerce-booking/booking-form/date-picker.php

### ✅ 3. **Edit the Template**
Once copied, you can safely modify the template inside your theme. WordPress and the plugin will now use your customized version instead of the original one.

### ✅ 4. **Clear Cache (if needed)**
After overriding the template, clear any cache (plugin or server-side) to ensure your changes take effect.

### 🧠 Notes
– Overridden templates are **update-safe**, meaning future plugin updates won’t overwrite your changes.
– Keep an eye on plugin updates, as the template structure might change. Compare and update your overrides if necessary.

If you want help overriding a specific template (e.g. changing the booking calendar, modifying price breakdown, etc.), let me know the file and change needed — I’ll guide you step by step.

User
public_html/wp-content/plugins/yith-woocommerce-booking-premium/templates/single-product/add-to-cart/booking-form
Assistant
Great! You're referring to overriding this plugin file:

public_html/wp-content/plugins/yith-woocommerce-booking-premium/templates/single-product/add-to-cart/booking-form.php

Here’s how to properly override this **`booking-form.php`** template in your theme:

### ✅ Step-by-Step: Override `booking-form.php` in Your Theme

#### 1. **Create the override directory in your theme**
Inside your active theme (or child theme), create the following directory:

wp-content/themes/your-theme/yith-woocommerce-booking/single-product/add-to-cart/

> Replace `your-theme` with your actual theme folder name.

#### 2. **Copy the template file**
Copy:

wp-content/plugins/yith-woocommerce-booking-premium/templates/single-product/add-to-cart/booking-form.php

To:

wp-content/themes/your-theme/yith-woocommerce-booking/single-product/add-to-cart/booking-form.php

#### 3. **Customize**
You can now edit `booking-form.php` inside your theme and customize it safely.

### ✅ Confirm It Works
To confirm your override is active:
– Make a small visible change (e.g., add a comment or static text).
– Visit a booking product page.
– View source or inspect the frontend to see if your change appears.

### 🔁 Keep It Update-Proof
After plugin updates, you should:
– Compare the updated `booking-form.php` with your overridden version.
– Merge changes if needed to keep your template compatible.

Let me know if you want to:
– Modify a specific part of the booking form (e.g., fields, calendar, time slots, etc.)
– Inject additional data or custom logic

I'll help you tailor the override.

User
/home/carplakes/public_html/wp-content/plugins/yith-woocommerce-booking-premium/templates/single-product/add-to-cart/booking-form/dates/start-date.php
Assistant
You're now referring to a **deeper template override**:

/home/carplakes/public_html/wp-content/plugins/yith-woocommerce-booking-premium/templates/single-product/add-to-cart/booking-form/dates/start-date.php

### ✅ To override this `start-date.php` file in your theme:

#### 1. **Create the folder structure inside your theme**
Inside your active theme (or child theme), create the following path:

wp-content/themes/your-theme/yith-woocommerce-booking/single-product/add-to-cart/booking-form/dates/

#### 2. **Copy the file**
Copy this file:

wp-content/plugins/yith-woocommerce-booking-premium/templates/single-product/add-to-cart/booking-form/dates/start-date.php

To this location in your theme:

wp-content/themes/your-theme/yith-woocommerce-booking/single-product/add-to-cart/booking-form/dates/start-date.php

### ✅ Notes

– Keep the **exact same folder structure**.
– You can now edit and customize the `start-date.php` file in your theme — the plugin will load **your version**.
– Make sure file permissions allow PHP to access it (generally `644` is fine).

### 🔁 Keep track of updates
After a plugin update:
– Check the plugin’s changelog or compare new `start-date.php` with your overridden one.
– Merge any changes if necessary to keep functionality intact.

Would you like help modifying the content inside `start-date.php` (e.g., changing the label, adding a tooltip, or customizing the input format)? I can assist with specific edits too.

User
not working'
Assistant
If your override for:

/wp-content/plugins/yith-woocommerce-booking-premium/templates/single-product/add-to-cart/booking-form/dates/start-date.php

in this theme path:

/wp-content/themes/your-theme/yith-woocommerce-booking/single-product/add-to-cart/booking-form/dates/start-date.php

**is not working**, here are the likely causes and how to fix them:

### ✅ 1. **Double-check the file path**
The correct override path inside your **active theme** (or child theme) must be **exactly**:

/wp-content/themes/your-active-theme/yith-woocommerce-booking/single-product/add-to-cart/booking-form/dates/start-date.php

✔️ Make sure:
– Folder names match **exactly** (especially `yith-woocommerce-booking`, **not** `yith-woocommerce-booking-premium`)
– The file is in the correct theme, not a disabled or parent theme if you're using a child theme.

### ✅ 2. **Ensure Theme is Active**
Confirm the theme you added the override to is the **active theme** under:

WP Admin → Appearance → Themes

### ✅ 3. **Clear Cache**
If you're using caching (plugin like W3 Total Cache, WP Super Cache, or even server cache like LiteSpeed or Cloudflare), clear it.

Also, try a hard refresh in your browser (`Ctrl + F5` or `Cmd + Shift + R`).

### ✅ 4. **Check Template Loading Mechanism**
Some advanced plugins (including YITH) sometimes load templates with their own filter-based logic instead of the usual `wc_get_template()` approach. YITH has been known to filter template locations.

#### Try this:
Add this to your `functions.php` to see where it's loading from:

add_filter( 'yith_wcbk_locate_template_debug', '__return_true' );

Then enable `WP_DEBUG` in `wp-config.php` and reload the booking product. It may output which path it's actually loading.

### ✅ 5. **Force Your Template Using Hook (as a last resort)**
If YITH is ignoring the override, you can force it with this workaround:

add_filter( 'yith_wcbk_locate_template', 'override_yith_booking_template', 10, 3 );
function override_yith_booking_template( $template, $template_name, $template_path ) {
    if ( $template_name === 'single-product/add-to-cart/booking-form/dates/start-date.php' ) {
        $custom = get_stylesheet_directory() . '/yith-woocommerce-booking/single-product/add-to-cart/booking-form/dates/start-date.php';
        if ( file_exists( $custom ) ) {
            return $custom;
        }
    }
    return $template;
}

Add this to your theme’s `functions.php`.

### ✅ 6. **Test with a Simple Change**
In your override file, add something obvious like:

echo "<p style='color:red;'>Custom Start Date Template Loaded</p>";

If it shows, your override is working.

### ✅ Final Checklist
– ✅ Folder name is `yith-woocommerce-booking`, **not** `…premium`
– ✅ Path and file structure matches exactly
– ✅ Active theme is correct
– ✅ Caches are cleared
– ✅ File has read permission (`644`)
– ✅ Debugging confirms whether the override is used

Would you like to share your folder and file structure (screenshot or path list)? I can verify if the layout is correct.

Leave a Comment

Your email address will not be published. Required fields are marked *