chris2201
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Pickup only showing as an option if postcode is enteredI think best practice is to add a note at cart page like “for customers with poscode 1xxxx, we offer local pickup. this option will be available at checkout”. manipulating the payment gateways is always a litte risky.
I can not confirm that fixed amount discount triggers the issue.
PS: I could prevent the behaviour by adding this code snippt:
add_filter( ‘woocommerce_get_cart_contents’, function( $cart_contents ) {
foreach ( $cart_contents as $key => $item ) {
if ( ! isset( $item[‘data’] ) || ! is_a( $item[‘data’], ‘WC_Product’ ) ) {
unset( $cart_contents[ $key ] );
}
}
return $cart_contents;
} );
Better way would be a workaround.I've been in contact with Germanized develpement and they sent me this:
Hi,
so the problem seems to lie within the Bundles plugin. In any case, the plugin causes (at least temporarily, meaning it's a timing issue) individual bundle components to be inserted into the WooCommerce cart object with missing data, specifically like this:array(1) { ["quantity"]=> float(2) }
It could very well also be a bug or incompatibility in the PayPal Payments plugin (which attempts to "simulate" the cart). If you use the following filter:add_filter( 'woosb_exclude_bundled', '__return_true' );
to prevent the individual bundle components from being added to the cart, the problem doesn't occur. In any case, this is not a bug in Germanized – Germanized merely reveals the issue. Any other plugin containing the following code would do the same:add_action( 'woocommerce_cart_calculate_fees', function() { WC()->cart->get_cart_contents_weight(); } );
So this snippet can be used to easily reproduce the issue even without Germanized. You can forward this to the developer of the Bundles plugin.Thank you for your answer. Two fatal errors are triggered when the issue occours:
“Call to a member function has_weight() on null”
This is error refers to PayPal Plugin and Germanized. Both seem to have problems how the bundle is added to cart. I contacted Germanized, they say I should contact you :/Forum: Plugins
In reply to: [Advanced AJAX Product Filters] Fatal error when going to update sectionInstalling 3.1.7.2 manually fixed the issue.
Forum: Plugins
In reply to: [Advanced AJAX Product Filters] Fatal error when going to update sectionHi Oleg,
3.1.4.6This is a really strange behaviour. I deleted the bundle and reproduced it. Same settings as before. Now it’s working and the amount is shown as 0.00 in PP logs like for all other bundles.
Forum: Plugins
In reply to: [WooCommerce] Restrict the purchase in my store according to opening hoursHey,
you can try this snippet:/*
* Snipped by Chris2201 and ChatGPT
*/
add_filter('woocommerce_get_price_html', 'conditionally_replace_add_to_cart_button', 10, 2);
add_action('woocommerce_single_product_summary', 'conditionally_show_custom_note', 25);
function conditionally_replace_add_to_cart_button($price, $product) {
// Define allowed days and hours
$allowed_days = [1, 2, 3, 4, 5]; // Monday to Friday (0 = Sunday, 6 = Saturday)
$start_hour = 10; // 10:00 AM
$end_hour = 19; // 7:00 PM
// Get current day and hour (server time)
$current_day = (int) current_time('w'); // 0 = Sunday, 6 = Saturday
$current_hour = (int) current_time('H'); // Hour in 24-hour format
// Check if the current day and hour are outside the allowed range
if (!in_array($current_day, $allowed_days) || $current_hour < $start_hour || $current_hour >= $end_hour) {
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
}
return $price; // Return the price as is
}
function conditionally_show_custom_note() {
// Define allowed days and hours
$allowed_days = [1, 2, 3, 4, 5]; // Monday to Friday (0 = Sunday, 6 = Saturday)
$start_hour = 10; // 10:00 AM
$end_hour = 19; // 7:00 PM
// Get current day and hour (server time)
$current_day = (int) current_time('w'); // 0 = Sunday, 6 = Saturday
$current_hour = (int) current_time('H'); // Hour in 24-hour format
// Check if the current day and hour are outside the allowed range
if (!in_array($current_day, $allowed_days) || $current_hour < $start_hour || $current_hour >= $end_hour) {
// Calculate reopening time
$reopen_time = $current_hour < $start_hour ? $start_hour : ($current_hour >= $end_hour ? $start_hour + 24 : 0);
$reopen_time_display = date('g:i A', mktime($reopen_time, 0, 0));
echo '<p class="woocommerce-info">We are currently closed. Add to cart will be available again at ' . $reopen_time_display . '.</p>';
}
}It’s only about the unit.
Look at your xml file posted.<g:unit_pricing_base_measure>per kg</g:unit_pricing_base_measure>This is wrong, you are using not the correct unit. It must be in this format
<g:unit_pricing_measure>50l</g:unit_pricing_measure>
<g:unit_pricing_base_measure>1l</g:unit_pricing_base_measure>The “per” is wrong regarding the taxonomy.
Forum: Plugins
In reply to: [WooCommerce] Payment gateways red notification dismissalwoocommerce without snippets is called shopify, right?
;).Just use “kg”.
Google does not recognize “per kg”, cause it’s not a unit per definition.Forum: Plugins
In reply to: [WooCommerce] Payment gateways red notification dismissalJust add this snippet and feel free 😉
function remove_payments_ad_tab(): void {
remove_menu_page("admin.php?page=wc-admin&task=woocommerce-payments");
}
add_action("admin_menu", "remove_payments_ad_tab", 999);Just Export the products with ID, Name, Price and Reduced Price. Update Reduced Price by hand or formula and import it, updating products.
Forum: Plugins
In reply to: [WooCommerce] CSV import goes wrong at endYou need to import variables (Type) first with all attributes.
Then you need to import variations (Type), assigning to parents ID.
You should have a column named “parent product”. There you write in the parent ID (e.g. id:3123) to assign it.
Easiest way to understand:
Add a variable product and add variations. Export it to get the right data structure.