Skip to content

Instantly share code, notes, and snippets.

@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 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 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 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
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
Created January 9, 2019 14:07
Add warning on top of estimated delivery date
add_filter( 'xa_estimated_delivery_cart_checkout_page_html_formatted_date', 'ph_estimated_delivery_add_warning_on_above_estimated_delivery',11,2 );
function ph_estimated_delivery_add_warning_on_above_estimated_delivery( $text, $test ) {
$message='<tr class="shipping"><th>Your cart having back-order products</th></tr>'; // add your message here
$text=$message.$text;
return $text;
}
@renjith-ph
renjith-ph / functions.php
Created January 14, 2019 07:52
Snippet to change product price to custom declared value and change unit of measurement for international shipping.
/* Snippet to change product price to custom declared value and change unit of measurement for international shipping.
Created at : 26 Nov 2018 PluginHive Plugins : https://www.pluginhive.com/plugins/
updated on : 14 Jan 2019
*/
add_filter( 'wf_ups_shipment_confirm_request_product_details', 'wf_ups_shipment_confirm_request_product_details', 10, 2 );
if( ! function_exists('wf_ups_shipment_confirm_request_product_details') ) {
function wf_ups_shipment_confirm_request_product_details( $product_details, $product_data ) {
if(!empty($product_data))
@renjith-ph
renjith-ph / functions.php
Created January 14, 2019 08:05
Snippet to add extra product description for UPS international shipping.
/* Snippet to add extra product description for UPS international shipping.
Created at : 14 Jan 2019 PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'wf_ups_shipment_confirm_request_product_details', 'ph_ups_add_extra_product_description_for_commercial_invoice', 10, 2 );
if( ! function_exists('ph_ups_add_extra_product_description_for_commercial_invoice') ) {
function ph_ups_add_extra_product_description_for_commercial_invoice( $product_details, $product_data ) {
$description=".Add your description here"; // add extra description in the commercial invoice.
$product_details['Description']=$product_details['Description'].$description;
@renjith-ph
renjith-ph / functions.php
Last active January 16, 2019 05:37
Snippet to redirect to checkout page after adding product to cart.
/* Snippet to redirect to checkout page after adding product to cart.
Created at : 16 Jan 2019 PluginHive Plugins : https://www.pluginhive.com/plugins/
https://gist.github.com/renjith-ph/0defbaf8a48d49ec61fc50add6b1b051
*/
function ph_change_redirect_url_after_adding_product_to_cart( $url ) {
$url = wc_get_checkout_url();
return $url;
}
add_filter( 'woocommerce_add_to_cart_redirect', 'ph_change_redirect_url_after_adding_product_to_cart' );
@renjith-ph
renjith-ph / functions.php
Last active January 16, 2019 06:45
Snippet to add custom message on top of checkout page if shipping methods are available.
/* Snippet to add custom message on top of checkout page if shipping methods are available.
Created at : 16 Jan 2019 PluginHive Plugins : https://www.pluginhive.com/plugins/
gist link: https://gist.github.com/renjith-ph/8f27c63d5a079d578ad3c7db00ece94b
*/
add_action( 'woocommerce_before_checkout_form', 'ph_add_custom_message_on_top_of_checkout_page_if_shipping_method_available', 10 );
function ph_add_custom_message_on_top_of_checkout_page_if_shipping_method_available()
{
$i=0;
$message="Do you qualify for a shipping discount? Give us a call at 541-419-6054"; // this message will display on top of checkout page