Skip to content

Instantly share code, notes, and snippets.

@renjith-ph
renjith-ph / functions.php
Created January 7, 2019 13:29
Snippet to get additional number of people from total persons.
/**
* Snippet to get additional number of people from total persons.
* Created at : 7 Jan 2019
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'phive_booking_total_person_details', 'phive_booking_get_additional_person_details', 10,2 );
function phive_booking_get_additional_person_details($total_person_detail,$product_id)
{
$minimum_person_details = array(
'323' => array( // Product Id
@renjith-ph
renjith-ph / functions.php
Last active January 10, 2019 14:11
Add backorder product message above the estimated delivery text
add_filter( 'xa_estimated_delivery_cart_checkout_page_html_formatted_date', 'ph_estimated_delivery_modify_cart_checkout_page_html',11,2 );
function ph_estimated_delivery_modify_cart_checkout_page_html( $text, $test ) {
global $woocommerce;
$items = $woocommerce->cart->get_cart();
$count=0;
foreach($items as $item => $values) {
$product_id=(wp_get_post_parent_id($values['data']->get_id())==0) ? $values['data']->get_id() : wp_get_post_parent_id($values['data']->get_id());
if($values['data']->get_stock_status()=='onbackorder')
{
@renjith-ph
renjith-ph / functions.php
Last active January 16, 2019 06:43
Add custom message on top of the checkout page
add_action( 'woocommerce_before_checkout_form', 'ph_add_custom_message_on_top_of_checkout_page', 10 );
function ph_add_custom_message_on_top_of_checkout_page()
{
wc_print_notice( __( 'Please enter complete address to get the accurate Estimated delivery date', 'woocommerce' ), 'notice' ); // You can replace notice with error or success
}
@renjith-ph
renjith-ph / functions.php
Last active January 2, 2019 13:41
Snippet to change product description in commercial invoice.
/**
* Snippet to change product description in commercial invoice.
* Created at : 28 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'ph_fedex_commodities','ph_fedex_commodities_description_customization',10,3);
function ph_fedex_commodities_description_customization($commodoties,$request,$fedex_packages) {
$products=array(
array( 'ids'=>array('199','122','789'),
@renjith-ph
renjith-ph / functions.php
Last active December 28, 2018 05:23
Snippet to to adjust importer price for international Shipment FedEx
/**
* Snippet to to adjust importer price for international Shipment FedEx
* Created at : 24 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'ph_fedex_commodities', 'ph_importer_price_adjust', 11, 3);
public function ph_importer_price_adjust($commodoties,$request,$fedex_packages){
$importer_price = array(
/* Experiment */
@renjith-ph
renjith-ph / functions.php
Last active December 28, 2018 08:17
Snippet to support Addon_Plugin_dividing_single_product.
/**
* Snippet to support Addon_Plugin_dividing_single_product.
* Created at : 24 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'wf_fedex_commodities', 'wf_fedex_request_update_commodity', 10, 3);
function wf_fedex_request_update_commodity($commodities,$request,$fedex_packages)
{
$final_product=array();
if(!empty($commodities))
@renjith-ph
renjith-ph / functions.php
Created December 18, 2018 14:55
Show hide accesspoint location based on chosen shipping methods.
/**
* Show hide accesspoint location based on chosen shipping methods.
* Created at : 18 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_action( 'wp_footer', 'conditionally_hidding_billing_custom_field' );
function conditionally_hidding_billing_custom_field(){
// Only on checkout page
@renjith-ph
renjith-ph / functions.php
Last active December 19, 2018 11:51
Split cart packages based on product category. PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Split cart packages based on product category.
* Created at : 17 Dec 2018
* Updated at : 19 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'woocommerce_cart_shipping_packages', 'wf_split_cart_by_shipping_class_group' );
function wf_split_cart_by_shipping_class_group($package){
/**
* Snippet to adjust rates based on package dimension.
* Created at : 14 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter('wf_ups_rate', 'wf_modify_ups_rate', 10, 2);
function wf_modify_ups_rate($xml, $packages){
if(empty($packages))
{
@renjith-ph
renjith-ph / functions.php
Last active January 21, 2019 05:52
Snippet to change estimate delivery if product is in back order.
/**
* Snippet to change estimate delivery if product is in back order.
* Created at : 08 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/renjith-ph/7ea21e6c60af0bab989ed2a57e98477e
*/
add_filter( 'woocommerce_get_availability', 'woocommerce_get_availability',12,2 );
function woocommerce_get_availability( $stock_arr ,$item) {