Skip to content

Instantly share code, notes, and snippets.

@PluginHive
PluginHive / function.php
Created June 27, 2019 12:41
Change Your calendar starting date based on your availability rule.
/**
* Change Your calendar starting date based on your availability rule.
* Created at : 27th June 2019
*/
add_filter( 'ph_booking_calendar_start_date', 'ph_booking_calendar_start_date',10, 2 );
function ph_booking_calendar_start_date($start_date,$product_id)
{
// return $message;
$fixed_availability_from = get_post_meta( $product_id, "_phive_fixed_availability_from", 1 );
@PluginHive
PluginHive / functions.php
Last active October 4, 2019 09:34
Code Snippet to rearrange shipping methods in cart page. Multi-Carrier Shipping Plugin for WooCommerce: https://www.pluginhive.com/product/multiple-carrier-shipping-plugin-woocommerce/
/**
* Snippet to rearrange shipping methods in cart page
* Created at : 18 July 2019
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/PluginHive/ccc1f3e0251f9056dc911e06edd30c92
**/
add_filter('woocommerce_package_rates', 'ph_sort_shipping_methods', 10, 2);
function ph_sort_shipping_methods($available_shipping_methods, $package)
@PluginHive
PluginHive / Style.css
Last active October 25, 2019 06:42
Customise Booking Calendar Font Size.
/*font size for week days, dates, time */
.ph-calendar-days li, .ph-calendar-weekdays li{
font-size:15px;
}
/*font size for month text*/
.ph-calendar-month ul li{
font-size: 15px !important;
}
.booking-info-wraper {
font-size: 15px !important;
@PluginHive
PluginHive / function.php
Created October 11, 2019 04:48
This snippet is used to display cost below the time displayed in time calendar(minutes and hours)
add_filter('ph_bookings_calendar_time_slot_value', 'display_cost_below_time', 10, 4); //This filter is used to display cost below the time displayed in time calendar(minutes and hours)
function display_cost_below_time($start_time_wp_format, $product_id, $interval, $start_time)
{
$currency = get_woocommerce_currency_symbol();
$weekdays_price = 400; //default price for weekdays(Monday to Friday)
//change price for weekdays according to time ranges
if (strtotime(date('H:i', $start_time)) >= strtotime('8am') && strtotime(date('H:i', $start_time)) <= strtotime('4pm')) //8am to 4pm
{
@PluginHive
PluginHive / Style.css
Last active January 11, 2020 07:11
hide non-available dates in time calendar
/* hide non-available dates in time calendar */
#ph-calendar-time li.ph-calendar-date.de-active.not-available {
display: none !important;
}
/* hide booked slots in time calendar */
#ph-calendar-time li.ph-calendar-date.booking-full.de-active {
display: none;
}
@PluginHive
PluginHive / function.php
Created October 17, 2019 10:34
Hide quantity in checkout page for bookable products
//snippet to hide quantity in checkout page for bookable products
add_filter( 'woocommerce_checkout_cart_item_quantity', 'woocommerce_checkout_cart_item_quantity_ph',10,3 );
function woocommerce_checkout_cart_item_quantity_ph($quantity_html,$cart_item,$key ) {
if(!empty($cart_item) && isset($cart_item['product_id']) && !empty($cart_item['product_id']))
{
$product=wc_get_product($cart_item['product_id']);
if(!empty($product) && !empty($product->get_type()) && $product->get_type()=='phive_booking')
{
return "";
}
@PluginHive
PluginHive / function.php
Last active October 24, 2019 13:11
Display total participant as order item quantity in email (If Consider each participant as separate booking is enabled)
function display_total_participant_in_email_order_item_quantity($quantity,$item =array()) {
if(!empty($item) && !empty($item->get_product_id()) ) {
$product_id=$item->get_product_id();
$_persons_as_booking = get_post_meta( $product_id, "_phive_booking_persons_as_booking", 1 );
if($_persons_as_booking=='yes')
{
$no_of_persons=$item->get_meta('Number of persons',true);
if(!empty($no_of_persons))
{
return $no_of_persons;
@PluginHive
PluginHive / function.php
Created October 24, 2019 10:34
Display total participant as quantity in cart page (If Consider each participant as separate booking is enabled)
function total_participant_in_woocommerce_cart_item_quantity($product_quantity, $cart_item_key, $cart_item) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if($_product->is_sold_individually())
{
$product_type = $_product->get_type();
if( $product_type == 'phive_booking' )
{
$_persons_as_booking = get_post_meta( $product_id, "_phive_booking_persons_as_booking", 1 );
if($_persons_as_booking=='yes' && array_key_exists('phive_booked_persons', $cart_item) && !empty($cart_item['phive_booked_persons']))
@PluginHive
PluginHive / function.php
Created October 24, 2019 10:36
Hide quantity in cart page
function hide_woocommerce_cart_item_quantity($product_quantity, $cart_item_key, $cart_item) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if($_product->is_sold_individually())
{
$product_type = $_product->get_type();
if( $product_type == 'phive_booking' )
{
$product_quantity = sprintf( '%s <input type="hidden" name="cart[%s][qty]" value="1" />','', $cart_item_key );
}
@PluginHive
PluginHive / function.php
Last active October 25, 2019 05:18
Hide quantity in cart , checkout, thank you page for bookable products
//cart page
function hide_woocommerce_cart_item_quantity($product_quantity, $cart_item_key, $cart_item) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if($_product->is_sold_individually())
{
$product_type = $_product->get_type();
if( $product_type == 'phive_booking' )
{
$product_quantity = sprintf( '%s <input type="hidden" name="cart[%s][qty]" value="1" />','', $cart_item_key );