Skip to content

Instantly share code, notes, and snippets.

View varun-pluginhive's full-sized avatar

varun-pluginhive

View GitHub Profile
@varun-pluginhive
varun-pluginhive / functions.php
Last active January 28, 2019 06:14
Snippet to reduce the shipping Cost for Particular Country and Shipping Method if Shipping class exists in cart. If all the Snippet Classes are available in cart then only snippet will affect the price. (AND Logic)
/**
* Snippet to reduce the shipping Cost for Particular Country and Shipping Method if Shipping class exists in cart.
* Created at : 15 Jan 2019
* Updated at : 15 Jan 2019
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/0d86c88cbe37b240d313588dbcced366
*/
if( ! function_exists('ph_reduce_shipping_method_cost') ) {
function ph_reduce_shipping_method_cost( $shipping_costs, $package ){
$shipping_classes = array( 'shipping_class_a', 'shipping_class_b', 'shipping_class_c' ); // Shipping Classes that should be in cart to reduce the price
@varun-pluginhive
varun-pluginhive / functions.php
Created January 2, 2019 14:04
Snippet to Add Handling Fee based on number of UPS Packages.
/**
* Snippet to Add Handling Fee based on number of UPS Packages.
* Created at : 02 Jan 2018
* Updated at : 02 Jan 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/82552099b55a500c4844df65d3e48723
*/
// Get the number of ups packages and set in session
add_filter( 'ph_ups_generated_packages', function( $ups_packages ) {
@varun-pluginhive
varun-pluginhive / functions.php
Created January 2, 2019 11:14
Snippet to hide the number of places left shown in WooCommerce Bookings on hover. WooCommerce Bookings And Appointments - https://www.pluginhive.com/product/woocommerce-booking-and-appointments/
/**
* Snippet to hide the number of places left shown in WooCommerce Bookings on hover.
* Created at : 02 Jan 2019
* Updated at : 02 Jan 2019
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link :
*/
add_action( 'woocommerce_after_single_product', function() {
?>
<script>
@varun-pluginhive
varun-pluginhive / style.css
Created January 2, 2019 08:48
Move the Right part of the WooCommerce product below the image.
div.summary.entry-summary{
display: contents !important;
}
@varun-pluginhive
varun-pluginhive / functions.php
Last active December 28, 2018 15:07
Snippet to convert city as Drop Down in WooCommerce Checkout. Note - Use only if you ship within that country
/**
* Snippet to convert city as Drop Down in WooCommerce Checkout
* Created at : 28 Dec 2018
* Updated at : 28 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/77383993417e6db5a71292a9548b1542
*/
add_filter( 'woocommerce_checkout_fields', function( $fields ) {
$city_args = wp_parse_args( array(
@varun-pluginhive
varun-pluginhive / style.css
Last active December 24, 2018 05:50
Style to change Woocommerce Bookings Calendar style on hover. WooCommerce Bookings And Appointments - https://www.pluginhive.com/product/woocommerce-booking-and-appointments/
/**
* Style to change Bookings Calendar style on hover.
* Created at : 24 Dec 2018
* Updated at : 24 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/8bd634b7d93253d45b88289e10119f12
*/
li.ph-calendar-date:hover{
background-color:red;
@varun-pluginhive
varun-pluginhive / functions.php
Created December 19, 2018 11:36
Snippet to check for PO Box Address in Shipping Line Address 1 and 2 and throw the error if found. PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Snippet to check for PO Box Address in Shipping Line Address 1 and 2 and throw the error if found.
* Created at : 19 Dec 2018
* Updated at : 19 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/89ae4de38f5a4f5ef7a65f2a67fa1e34
*/
add_action( 'woocommerce_after_checkout_validation', function($data) {
$text_to_check = array( 'PO', 'PO.', 'PoBox' ); // Text to check in shipping address Line 1 and 2
$message = "PO Box is not allowed please check your address.";
@varun-pluginhive
varun-pluginhive / functions.php
Last active June 28, 2023 09:40
Snippet to change Booking Product font-size of Time in Product Page. WooCommerce Bookings And Appointments - https://www.pluginhive.com/product/woocommerce-booking-and-appointments/
/**
* Snippet to change Booking Product font-size of Time in Product Page.
* Created at : 19 Dec 2018
* Updated at : 19 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/78996c9a57e98cf319a9b0f9d44a1e6a
*/
add_action( 'woocommerce_after_single_product', function() {
?>
<script>
@varun-pluginhive
varun-pluginhive / functions.php
Last active June 28, 2023 09:43
Add message to the WooCommerce cart page.
/**
* Add message to the cart page.
* Created at : 17 Dec 2018
* Updated at : 17 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/9938137d3a7f8e6b910109267f61e88f
*/
add_action( 'woocommerce_init', function(){
$message = "Please proceed to the Checkout page to get the UPS AccessPoint option as delivery option."; // Provide the message
$request_url = $_SERVER['REQUEST_URI'];
@varun-pluginhive
varun-pluginhive / functions.php
Created December 3, 2018 11:36
Snippet to set minimum weight of UPS Package. WooCommerce UPS Shipping Plugin with Print Label - https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/
/**
* Snippet to set minimum weight of UPS Package.
* Created at : 03 Dec 2018
* Updated at : 03 Dec 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/a59ff76a71e33dd97303f931375d2ad5
*/
add_filter( 'ph_ups_generated_packages', function( $packages ){
$min_weight = 0.5; // Minimum Weight of Package
foreach( $packages as &$package ) {