This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_footer', 'scripts_for_adding_country_prefix_on_billing_phone' ); | |
function scripts_for_adding_country_prefix_on_billing_phone(){ | |
?> | |
<script type="text/javascript"> | |
( function( $ ) { | |
$( document.body ).on( 'updated_checkout', function(data) { | |
var ajax_url = "<?php echo admin_url('admin-ajax.php'); ?>", | |
country_code = $('#billing_country').val(); | |
var ajax_data = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_registration_auth_new_customer', '__return_false' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function recently_viewed_products_shortcode( $atts ) { | |
$viewed_products = ! empty( $_COOKIE['woocommerce_recently_viewed'] ) ? (array) explode( '|', wp_unslash( $_COOKIE['woocommerce_recently_viewed'] ) ) : array(); // @codingStandardsIgnoreLine | |
$viewed_products = array_reverse( array_filter( array_map( 'absint', $viewed_products ) ) ); | |
if ( empty( $viewed_products ) ) return; | |
$product_ids = implode( ',', $viewed_products ); | |
// if have some attributes | |
$attr = ''; | |
if( $atts ){ | |
foreach ( $atts as $key => $value ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function show_no_of_people_added_in_cart(){ | |
global $wpdb, $product; | |
$in_basket = 0; | |
$wc_session_data = $wpdb->get_results( "SELECT session_key FROM {$wpdb->prefix}woocommerce_sessions" ); | |
$wc_session_keys = wp_list_pluck( $wc_session_data, 'session_key' ); | |
if( $wc_session_keys ) { | |
foreach ( $wc_session_keys as $key => $_customer_id ) { | |
// if you want to skip current viewer cart item in counts or else can remove belows checking | |
if( WC()->session->get_customer_id() == $_customer_id ) continue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function modify_wc_email_order_items_args( $args ) { | |
if( isset( $args['order'] ) && $args['order'] ){ | |
$items = ( isset( $args['items'] ) && $args['items'] ) ? $args['items'] : array(); | |
if( $items ) : | |
$cat_wisw_pros = array(); | |
foreach ( $items as $item_id => $item ){ | |
$product_id = $item['product_id']; | |
$cat_ids = wp_get_post_terms( $product_id, 'product_cat', array( 'fields' => 'ids' ) ); | |
foreach ( $cat_ids as $id ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function remove_site_health_test( $tests ) { | |
if( isset( $tests['direct']['php_version'] ) unset( $tests['direct']['php_version'] ); // remove php version check | |
if( isset( $tests['async']['background_updates'] ) unset( $tests['async']['background_updates'] ); // remove background update | |
return $tests; | |
} | |
add_filter( 'site_status_tests', 'remove_site_health_test' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function add_quantity_in_woocommerce_loop( $html, $product ) { | |
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { | |
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">'; | |
$html .= woocommerce_quantity_input( array(), $product, false ); | |
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>'; | |
$html .= '</form>'; | |
} | |
return $html; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wp_handle_upload_prefilter( $file ){ | |
$tempImg = getimagesize( $file['tmp_name'] ); | |
$width= $img[0]; | |
$height =$img[1]; | |
// lets restrict image size (width*height) 400*640 minimum | |
if ( $minimum['width'] < 400 ) | |
return array( "error" => "Image dimensions are too small. Minimum width is 400px. Uploaded image width is 400 px" ); | |
elseif ( $minimum['height'] < 640 ) | |
return array( "error" => "Image dimensions are too small. Minimum height is 640px. Uploaded image height is 640 px" ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function add_allow_upload_extension_exception( $types, $file, $filename, $mimes ) { | |
// Do basic extension validation and MIME mapping | |
$wp_filetype = wp_check_filetype( $filename, $mimes ); | |
$ext = $wp_filetype['ext']; | |
$type = $wp_filetype['type']; | |
if( in_array( $ext, array( 'ai', 'eps' ) ) ) { // if follows illustrator files have | |
$types['ext'] = $ext; | |
$types['type'] = $type; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function add_custom_upload_mimes( $mimes_types ) { | |
$mimes_types['eps'] = 'application/postscript'; // Adobe Illustrator files | |
$mimes_types['ai'] = 'application/postscript'; // Adobe Illustrator files | |
return $mimes_types; | |
} | |
add_filter( 'upload_mimes', 'add_custom_upload_mimes' ); |
NewerOlder