Skip to content

Instantly share code, notes, and snippets.

@PluginHive
PluginHive / function.php
Created January 20, 2020 10:06
Customize message which is displaying after add to cart a booking product
add_filter( 'wc_add_to_cart_message_html', 'phive_added_to_cart_message', 11,2 );
function phive_added_to_cart_message( $message, $products ){
$added_to_cart_message='Booking Done. Please check cart for payment.'; //make your changes
$is_booking_product = false;
foreach ($products as $product_id => $quantity) {
if( ph_is_bookable_product($product_id) ){
$is_booking_product = true;
break;
}
@PluginHive
PluginHive / function.php
Last active January 18, 2020 07:36
Restrict the maximum number of checkbox addon user can select in the frontend
add_action('wp_footer','scripting');
function scripting()
{
?>
<script type="text/javascript">
// console.clear();
// console.log("started check box condition");
jQuery(document).ready(function($){
var max_selection=2; // change this value
@PluginHive
PluginHive / function.php
Created December 21, 2019 07:21
Change block count based on number of clicks in non adjacent booking plugin for participant rule
add_filter( 'ph_non_adjacent_bookings_multiply_cost_with_block_before_calc', 'ph_non_adjacent_bookings_multiply_cost_with_block_before_calc',10,2 );
function ph_non_adjacent_bookings_multiply_cost_with_block_before_calc( $true_false,$product_id='' ) {
return true;
}
add_filter( 'ph_multiple_non_adjacent_participant_applied_cost', 'ph_multiple_non_adjacent_participant_applied_cost_condition',10,2 );
function ph_multiple_non_adjacent_participant_applied_cost_condition( $query='' ) {
return false;
@PluginHive
PluginHive / function.php
Created December 12, 2019 12:38
Code snippet to display the number of days selected by the customer for a booking in the WooCommerce Email.
add_filter( 'woocommerce_email_order_item_quantity', 'display_number_of_days_booked_as_quantity_in_order_emails',10,2 );
function display_number_of_days_booked_as_quantity_in_order_emails($quantity,$item =array())
{
if(!empty($item) && !empty($item->get_product_id()) )
{
$product_id = $item->get_product_id();
$from_date = $item->get_meta('From',true);
$to_date = $item->get_meta('To',true);
if (!empty($from_date))
{
@PluginHive
PluginHive / function.php
Last active December 2, 2019 07:04
Hide the notice which displays after placing a booking
add_filter( 'ph_booking_add_to_cart_message_html', 'ph_booking_hide_add_to_cart_message_html' );
function ph_booking_hide_add_to_cart_message_html( $message='' ) {
// return $message;
return '';
}
@PluginHive
PluginHive / functions.php
Last active December 2, 2019 06:24
Snippet to show shipping method on order weight. PluginHive Plugins : https://www.pluginhive.com/product-category/woocommerce-plugin/
/**
* Snippet to show shipping method on order weight
* Created at : 2 December 2019
* PluginHive Plugins : https://www.pluginhive.com/product-category/woocommerce-plugin/
* Gist Link : https://gist.github.com/PluginHive/bc669f7d85124a18c457c0d27a00a229
**/
add_filter( 'woocommerce_package_rates', 'ph_show_shipping_method_on_order_weight', 10, 2 );
function ph_show_shipping_method_on_order_weight( $available_shipping_methods, $package ) {
@PluginHive
PluginHive / function.php
Created November 29, 2019 05:34
hide booking end time in the booking info text
add_filter( 'ph_bookings_display_booking_end_time', 'check_display_booking_end_time' );
function check_display_booking_end_time( $default=true ) {
return false;
// return true;
}
@PluginHive
PluginHive / Style.css
Created November 28, 2019 11:30
Book Now Button issue with Elementor plugin
.woocommerce div.product.elementor form.cart:not(.grouped_form):not(.variations_form){
display: block !important;
}
@PluginHive
PluginHive / function.php
Created November 5, 2019 06:35
Add text in product page price
function remove_currency_in_wc_price( $price_html ) {
global $product;
if( !empty($product) && is_a( $product, 'WC_Product_phive_booking' ) && !is_cart() && !is_checkout() && !is_ajax() ) {
$display_cost=get_post_meta( $product->get_id(), '_phive_booking_pricing_display_cost', 1 );
if(!empty($display_cost))
{
$arr=explode('<span class="woocommerce-Price-currencySymbol">', $price_html);
$arr2=explode('</span>', $arr[1]);
return $arr[0].$arr2[1];
}
@PluginHive
PluginHive / Style.css
Last active October 29, 2019 11:43
Customise booking calendar colour
/*month colour*/
.ph-calendar-month ul li {
color: #ffffff;
}
/*week days, day colour*/
.ph-calendar-days li, .ph-calendar-weekdays li {
color: #0d0d0d;
}