Skip to content

Instantly share code, notes, and snippets.

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

Niloy Niloys7

🏠
Working from home
View GitHub Profile
@Niloys7
Niloys7 / sample_products.xml
Created December 24, 2025 13:32
WooCommerce demo product XML file for WordPress playground -
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is a WordPress eXtended RSS file generated by WordPress as an export of your site.
It contains information about your site's posts, pages, comments, categories, and other content.
You may use this file to transfer that content from one site to another.
This file is not intended to serve as a complete backup of your site.
To import this information into a WordPress site follow these steps:
1. Log in to that site as an administrator.
2. Go to Tools: Import in the WordPress admin panel.
@Niloys7
Niloys7 / functions.php
Created April 2, 2025 11:29
Show a custom checkbox before the "Place Order" button on the checkout page if the cart contains deposit items.
<?php
// Add the required checkbox right before the "Place Order" button
// plugin: https://www.codeixer.com/woocommerce-deposits-plugin/
add_action('woocommerce_review_order_before_submit', 'custom_checkout_terms_checkbox', 9);
function custom_checkout_terms_checkbox() {
if(!cidw_cart_have_deposit_item()){
return;
}
?>
<p class="form-row terms-field" style="margin-bottom: 15px;">
@Niloys7
Niloys7 / config.php
Last active August 14, 2025 03:50
one click demo import (OCDI) is not adding elementor global options
/**
* Function to perform setup after importing data.
* This function assigns the front page and the posts page (blog page) based on the imported demo.
* @param array $selected_import The selected import data.
* @link https://www.codeixer.com/addressing-the-issue-of-one-click-demo-import-not-add-elementor-global-options/
*/
function cdx_after_import_setup( $selected_import ) {
// Import Elementor kit data.
@Niloys7
Niloys7 / functions.php
Created August 6, 2023 14:39
Order status manager email template Customize by 3rd party plugin
/**
* https://brightplugins.com/docs/how-to-edit-or-override-the-email-templates-for-custom-order-status/
*/
add_filter( 'viwec_accept_email_type', function ($email_types) {
$email_types[] = 'bvos_custom_pickup-point'; // replace it
return $email_types;
}, 9999 );
function register_email_type( $emails ) {
@Niloys7
Niloys7 / order_email_template.php
Created February 13, 2023 12:05
Add Content in custom status email template
/**
* How to edit or override the email templates for custom order status?
* @link https://brightplugins.com/docs/how-to-edit-or-override-the-email-templates-for-custom-order-status/
*/
add_action( 'woocommerce_email_before_order_table', 'brightplugins_add_content_specific_email', 20, 4 );
function brightplugins_add_content_specific_email( $order, $sent_to_admin, $plain_text, $email ) {
if ( $email->id == 'bvos_custom_transit' ) {
echo '<p>Content for Transit Status</p>';
@Niloys7
Niloys7 / change_order_status_on_preorder_date.php
Created July 12, 2022 00:13 — forked from niloyBrightVessel/change_order_status_on_preorder_date.php
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';
}
@Niloys7
Niloys7 / hide_x_button.php
Created February 10, 2022 21:16
Hide Remove Button [x] from Specific product from WooCommerce Cart
add_filter( 'woocommerce_cart_item_remove_link', 'ns_cart_item_remove_link', 20, 2 );
/**
* @snippet Hide Remove Button [x] from Specific product from WooCommerce Cart
* @author Niloy , iamniloy.com
* @param $button_link
* @param $cart_item_key
* @return mixed
*/
function ns_cart_item_remove_link( $button_link, $cart_item_key ) {
//SET HERE your specific products IDs
@Niloys7
Niloys7 / preorder_avaiable_date_text.php
Last active January 3, 2023 16:56
Filter for preorder available date text on single product page
add_filter('preorder_avaiable_date_text',function($text , $id){
$custom_date_format = date( 'D M d, Y', strtotime( get_post_meta($id, '_pre_order_date', true)) );
return '<span class="preorder-avaiable-date-text">Available on '.$custom_date_format.'</span>';
},10,2);
@Niloys7
Niloys7 / functions.php
Created August 9, 2021 20:04
Update preorder date programmatically for Variable products
add_action('wp_head','bp_preorder_script');
function bp_preorder_script() {
$args = array(
'post_type' => 'product_variation',
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
@Niloys7
Niloys7 / dcpt.php
Created April 17, 2021 12:44
//Delete all posts of a custom post type with its included post meta data and taxonomies by using wpdb
function deletePostType($postType = ''){
global $wpdb;
$result = $wpdb->query(
$wpdb->prepare("
DELETE posts,pt,pm
FROM {$wpdb->prefix}posts posts
LEFT JOIN {$wpdb->prefix}term_relationships pt ON pt.object_id = posts.ID
LEFT JOIN {$wpdb->prefix}postmeta pm ON pm.post_id = posts.ID
WHERE posts.post_type = %s