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 July 25, 2025 08:45
Here are the specific problematic code sections from your functions.php that are likely causing issues with Product Feed Pro:
<?php
// ❌ PROBLEM 1: Aggressive file renaming interfering with feed generation
function tp_random_media_filename($filename) {
// Skip randomization for WooCommerce export files
if (did_action('woocommerce_product_export_batch_export_start') ||
did_action('woocommerce_product_exporter_start_export') ||
strpos($filename, 'wc-product-export') !== false) {
return $filename;
}
@TanvirHasan19
TanvirHasan19 / functions.php
Created July 18, 2025 00:28
Remove WCVendors Pro split shipping functionality
/**
* Remove WCVendors Pro split shipping functionality
*
* @since 1.0.0
*/
function wcv_remove_split_shipping_packages() {
// Check if WCVendors Pro is active and shipping controller exists
if ( ! class_exists( 'WCVendors_Pro' ) ) {
return;
@TanvirHasan19
TanvirHasan19 / functions.php
Created July 10, 2025 10:37
Hide wholesale prices for guest users only - show regular prices instead
function wwp_hide_wholesale_price_for_guests($wholesale_price_html, $price, $product, $user_wholesale_role, $wholesale_price_title_text, $raw_wholesale_price, $source, $wholesale_price) {
// Only hide wholesale prices for guest users (not logged in)
if (!is_user_logged_in()) {
// Return only the regular price, no wholesale pricing
return $price;
}
// For logged-in users, return the wholesale price as normal
return $wholesale_price_html;
@TanvirHasan19
TanvirHasan19 / functions.php
Created May 14, 2025 07:22
Force downloadable checkbox to be checked
/**
* Force downloadable checkbox to be checked using MutationObserver
*/
function force_downloadable_checkbox_checked() {
?>
<script type="text/javascript">
(function() {
// Function to check the downloadable checkbox
function checkDownloadable() {
var downloadableCheckbox = document.getElementById('_downloadable');
@TanvirHasan19
TanvirHasan19 / functions.php
Created May 13, 2025 07:33
Modify decimal separators for price fields specifically for TikTok Product Catalog feeds to follow ISO 4217 standards.
function replace_decimal_separator_for_tiktok( $product_data, $feed = null ) {
// Check if this is a TikTok Product Catalog feed
$is_tiktok_feed = false;
// First check by feed title if available
if ( isset($feed) && is_object($feed) && isset($feed->title) && strpos($feed->title, 'TikTok') !== false ) {
$is_tiktok_feed = true;
}
// Check by feed templates as defined in the channel statics
@TanvirHasan19
TanvirHasan19 / functions.php
Created May 8, 2025 06:49
Restrict a Shop Manager role to only access Product Feed functionality while removing their access to broader WooCommerce menus.
/**
* Modify capabilities to allow Shop Manager to access only Product Feed menus
*
* @return string Required capability for accessing product feed menus
*/
function allow_feed_menus_to_shop_manager() {
// Create a custom capability instead of using manage_woocommerce
return 'manage_adtribes_product_feeds';
}
add_filter( 'woosea_user_cap', 'allow_feed_menus_to_shop_manager' );
@TanvirHasan19
TanvirHasan19 / functions.php
Created April 22, 2025 11:47
Update product lookup table prices
/**
* Update product lookup table prices
*
* @param int $product_id The product ID
* @param array $postdata The product form data
*
* @return void
*/
function dokan_update_product_lookup_prices( $product_id, $postdata ) {
if ( ! $product_id ) {
@TanvirHasan19
TanvirHasan19 / functions.php
Created March 7, 2025 00:34
hide the "not-right-now-btn" element
/**
* Hide "Not right now" button in Dokan vendor setup wizard
*/
/**
* Add CSS and JavaScript to hide the "Not right now" button
*/
function dokan_hide_not_right_now_button() {
// Only apply on the dokan-seller-setup page
if ( isset( $_GET['page'] ) && 'dokan-seller-setup' === $_GET['page'] ) {
@TanvirHasan19
TanvirHasan19 / functions.php
Created March 4, 2025 08:16
Vendor contact form on the vendor dashbaord using menu manager
function add_contact_form_to_vendor_dashboard( $nav_items ) {
// Add contact form menu to the vendor dashboard
$nav_items['contact_form'] = [
'title' => __( 'Contact Form', 'dokan' ),
'icon' => '<i class="fa fa-envelope"></i>',
'url' => dokan_get_navigation_url( 'contact-form' ),
'pos' => 71, // Position in the menu (adjust as needed)
'permission' => 'dokan_view_contact_form_menu'
];
@TanvirHasan19
TanvirHasan19 / functions.php
Created January 16, 2025 09:50
Add Custom Fields to the Vendor Registration Form and add those fields in the Store Settings form
#-- Vendor Registration Form Custom Field HTML --#
function form_custom_field_html() {
?>
<p class="form-row form-group form-row-wide">
<label for="referred-by"><?php esc_html_e( 'Referred By', 'dokan-lite' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text form-control" name="dokan_referred_by" id="referred-by" value="<?php echo ! empty( $data['dokan_referred_by'] ) ? esc_attr( $data['dokan_referred_by'] ) : ''; ?>" required="required" />
</p>
<p class="form-row form-group form-row-wide">
<label for="gst-id"><?php esc_html_e( 'GST ID', 'dokan-lite' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text form-control" name="dokan_gst_id" id="gst-id" value="<?php echo ! empty( $data['dokan_gst_id'] ) ? esc_attr( $data['dokan_gst_id'] ) : ''; ?>" required="required" />