Skip to content

Instantly share code, notes, and snippets.

View niloyBrightVessel's full-sized avatar
🏠
Working from home

niloyBrightVessel

🏠
Working from home
View GitHub Profile
@niloyBrightVessel
niloyBrightVessel / short.php
Created March 19, 2021 13:52
custom query for show products on catgeory page based on attribute
/*
* List WooCommerce Products by attributes
*
* ex: [woo_products_by_attributes attribute="colour" per_page="5"]
*/
function woo_products_by_attributes_shortcode( $atts, $content = null ) {
global $woocommerce, $woocommerce_loop;
@niloyBrightVessel
niloyBrightVessel / change_order_status_on_preorder_date.php
Created February 1, 2021 12:32
Change Preorder status after preoder date arrived
add_filter('change_order_status_on_preorder_date','bp_change_order_status',20,1);
function bp_change_order_status($status){
return 'processing';
}
@niloyBrightVessel
niloyBrightVessel / gist:5dcbeebed6e942df4f4cff92b53c91fe
Created February 1, 2021 11:17
Display a preorder date under cart item name in checkout
add_filter('woocommerce_cart_item_name', 'bpPreorderDateInCheckoutItems',10,3);
// Display a preorder date under cart item name in checkout
function bpPreorderDateInCheckoutItems($p_name,$cart_item, $cart_item_key)
{
// Here below define your shipping class slug
$isPreoder = get_post_meta($cart_item['product_id'], '_is_pre_order', true);
$PreOrderDate = get_post_meta($cart_item['product_id'], '_pre_order_date', true);
if ('yes' == $isPreoder && strtotime($PreOrderDate) > time()) {
$timeFormat = date_i18n(get_option('date_format'), strtotime($PreOrderDate)) ;
@niloyBrightVessel
niloyBrightVessel / gist:ad6fa3ce172a7cfefc846de7afca5103
Last active March 9, 2021 09:25
Add html wrapper Preorder notice
add_filter('preorder_avaiable_date_text', 'bpCustomMessage',10);
add_filter('preorder_avaiable_date_text_loop', 'bpCustomMessage',10);
add_filter('preorder_avaiable_date_text_cart', 'bpCustomMessage',10);
function bpCustomMessage($text){
$data = $text;
return '<div class="preorder-date-wrapper">'.$data.'</div>';
@niloyBrightVessel
niloyBrightVessel / gist:c546541e76bf9fa43da6c4d17f9dca97
Created November 26, 2020 08:27
Override Prerorder product notice on cart page
add_filter('preorder_avaiable_date_text_cart','bp_override_preorder_cart_notice',10,2);
function bp_override_preorder_cart_notice($notice,$diff){
$notice = '<br/><small style="color:green"> '.sprintf(__("Note: this item will be available for shipping in %s days</small>",'preorders'),$diff).'</small>';
return $notice;
}