Skip to content

Instantly share code, notes, and snippets.

View TanvirHasan19's full-sized avatar
🏘️
Working from home

Tanvir Hasan TanvirHasan19

🏘️
Working from home
View GitHub Profile
@TanvirHasan19
TanvirHasan19 / functions.php
Created November 6, 2025 04:31
WC Vendors Google Merchant Center Integration
<?php
/**
* WC Vendors Google Merchant Center Integration
*
* This code provides the missing functionality to retrieve vendor shipping data
* from a product object for Google Merchant Center feed generation.
*/
/**
* Get vendor ID from a WooCommerce product object
@TanvirHasan19
TanvirHasan19 / functions.php
Created November 3, 2025 10:27
Limit Points Redemption to Percentage of Cart Value
// ==============================================================================
// LPFW Percentage Limit - Limit Points Redemption to Percentage of Cart Value
// ==============================================================================
add_action('admin_footer', function() {
$screen = get_current_screen();
if (!$screen || (strpos($screen->id, 'woocommerce') === false && strpos($screen->id, 'acfw') === false)) {
return;
}
?>
<script type="text/javascript">
@TanvirHasan19
TanvirHasan19 / functions.php
Created October 30, 2025 04:19
Adds a username field to WC Vendors Signup and uses it when creating the user.
/**
* Username Field
* Description: Adds a username field to WC Vendors Signup and uses it when creating the user.
*/
defined( 'ABSPATH' ) || exit;
add_filter( 'wcv_signup_form_config', function( $config ) {
$config = is_array( $config ) ? $config : array();
@TanvirHasan19
TanvirHasan19 / functions.php
Created October 23, 2025 04:12
Add vendor header on Elementor single product template.
/**
* Add vendor header on Elementor single product template.
*/
add_action( 'wp_footer', 'wcv_elementor_js_vendor_header' );
function wcv_elementor_js_vendor_header() {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
@TanvirHasan19
TanvirHasan19 / functions.php
Created September 2, 2025 06:55
WC Vendors - Regenerate Missing Vendor Orders
<?php
/**
* WC Vendors - Regenerate Missing Vendor Orders
*
* This script regenerates missing vendor sub-orders for cases where:
* - Products were initially published under Administrator
* - Product author was later corrected to vendor
* - Commission was recalculated but vendor orders are missing from Orders menu
*
* IMPORTANT:
@TanvirHasan19
TanvirHasan19 / functions.php
Created August 28, 2025 03:51
Helper function to log to WooCommerce status log
// Helper function to log to WooCommerce status log
function wcv_log_to_wc_status( $message, $level = 'info' ) {
if ( function_exists( 'wc_get_logger' ) ) {
$logger = wc_get_logger();
$logger->log( $level, $message, array( 'source' => 'wcv-import-improvements' ) );
}
// Also log to WordPress error log for backup
error_log( '[WCV Import] ' . $message );
}
@TanvirHasan19
TanvirHasan19 / functipns.php
Created August 20, 2025 08:30
Reorder payment gateways for wholesale customers only. For WooCommerce block checkout
/**
* Ensure Checkout Block respects wholesale payment method order by setting
* the paymentMethodSortOrder asset data early.
*/
add_action( 'woocommerce_blocks_checkout_enqueue_data', function () {
// Wholesale check via WooCommerce Wholesale Prices Premium
global $wc_wholesale_prices_premium;
$user_wholesale_role = '';
if (
isset( $wc_wholesale_prices_premium ) &&
@TanvirHasan19
TanvirHasan19 / functions.php
Created August 20, 2025 08:28
Reorder payment gateways for wholesale customers only. For WooCommerce Classic checkout
/**
* Reorder payment gateways for wholesale customers only.
*/
add_filter( 'woocommerce_available_payment_gateways', function ( $gateways ) {
// Apply only during checkout, including AJAX and REST requests used by Checkout/Blocks.
if (
function_exists( 'is_checkout' )
&& ! is_checkout()
&& ! ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() )
&& ! ( defined( 'REST_REQUEST' ) && REST_REQUEST )
@TanvirHasan19
TanvirHasan19 / functions.php
Created August 7, 2025 03:11
Reformat the form to British banking details
add_action( 'wp_head', 'wcv_bank_fields_2_column_reorder' );
function wcv_bank_fields_2_column_reorder() {
// Only load on vendor dashboard pages
if ( ! is_user_logged_in() ) return;
?>
<style type="text/css">
/* Create 2-column layout for bank fields */
.wcv-payment-tab,
[class*="payment"] form,
@TanvirHasan19
TanvirHasan19 / index.html
Last active August 6, 2025 10:50
Animation
import React, { useEffect, useState } from 'react';
import { motion, useScroll, useTransform } from 'framer-motion';
export default function Transforming() {
const { scrollYProgress } = useScroll();
const [isAnimated, setIsAnimated] = useState(false);
// Track scroll progress and toggle animation based on scroll position
useEffect(() => {
const unsubscribe = scrollYProgress.onChange((latest) => {