Skip to content

Instantly share code, notes, and snippets.

Avatar

Kartik Parmar kartikparmar

  • Mumbai
View GitHub Profile
@kartikparmar
kartikparmar / functions.php
Last active Nov 23, 2020
Updating Booking Status - Rich
View functions.php
<?php
function woocommerce_thankyou_change_order_status( $order_id ) {
if ( ! $order_id ) return;
$order = wc_get_order( $order_id );
if ( $order->get_status() == 'processing' ){
$order->update_status( 'pending' );
@kartikparmar
kartikparmar / functions.php
Created Jul 22, 2020
Changing the steps quantity to 2 for all the WooCommerce products
View functions.php
<?php
/*
* Changing the steps quantity to 2 for all the WooCommerce products
*/
function woocommerce_quantity_input_step_callback( $step, $product ) {
$step = 2;
return $step;
}
@kartikparmar
kartikparmar / functions.php
Created Jun 13, 2020
Change Proceed to Checkout button
View functions.php
<?php
function woocommerce_button_proceed_to_checkout(){
?>
<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="checkout-button button alt wc-forward">
<?php esc_html_e( 'Proceed to Make Payment', 'woocommerce' ); ?>
</a>
<?php
}
@kartikparmar
kartikparmar / functions.php
Created Jun 13, 2020
Do not allow product to be purchased if particular is present in the cart.
View functions.php
<?php
function wc_purchasable_or_not( $product_id, $status = true ) {
// key : ID of Product where you want to hide Add to Cart.
// value : Array of Product IDs which are present in the cart then hide Add to Cart button for Product ID set in key
$product_check = array(
'2701' => array( '2848', '2563', '1253' ),
'2245' => array( '2848', '2563', '1253' ),
@kartikparmar
kartikparmar / functions.php
Created Jun 12, 2020
Changing pickup fields label
View functions.php
<?php
function orddd_change_pickup_date_label_callback(){
return __( 'New Pickup Date Label', 'order-pickup-date' );
}
add_filter( 'orddd_change_pickup_date_label', 'orddd_change_pickup_date_label_callback' );
function orddd_change_pickup_time_label_callback(){
return __( 'New Pickup Time Slot Label', 'order-pickup-date' );
@kartikparmar
kartikparmar / functions.php
Created Jun 6, 2020
Change Date Comparison for Advance Booking Period. Using this filter you can prepare date based on to time of the booking.
View functions.php
<?php
/**
* Change Date Comparison for Advance Booking Period.
* Using this filter you can prepare date based on to time of the booking.
*
* @param string $time Date and Time String
* @param string $date Date
* @param string $from From Time
* @param string $to To Time
@kartikparmar
kartikparmar / functions.php
Created May 11, 2020
Additional Information in Google Event Summary and Description
View functions.php
<?php
/**
* Additonal Information in Google Event Summary
*
* @param string $summary Inforation of the Google Event Summary.
* @param obj $data Prepared App data for Gcal Calculation.
*/
function bkap_google_event_summary_callback( $summary, $data ){
@kartikparmar
kartikparmar / functions.php
Created Feb 10, 2020
Hide products of particular categories being displayed on the Shop page only for guest users
View functions.php
/**
* Exclude products from a particular category on the shop page
*/
function ts_pre_get_posts_query( $q ) {
if ( ! is_user_logged_in() ) { // Hide below mentioned categories for guest user
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
@kartikparmar
kartikparmar / functions.php
Created Jan 28, 2020
Hide categories from shop page only for guest users.
View functions.php
<?php
/**
* Show products only of selected category.
*/
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
$hide_category = array();
@kartikparmar
kartikparmar / functions.php
Created Dec 12, 2019
Hide WooCommerce Category and its sub-categories from Shop page
View functions.php
<?php
/**
* Show products only of selected category.
*/
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
$hide_category = array( 126 ); // Ids of the category you don't want to display on the shop page