dev
Forum Replies Created
-
Hello,
We have chosen to remove postSMTP from all 16 sites and the performance concerns have now been removed from newrelic reports.
We can only provide partial historical information from new relic but these issues were seen from low traffic basic sites, to our most complex and plugin heavy multisite. Given this was seem across a wide range, we do not believe its site specific.Thanks for the reply.
I appreciate you passing this to your development team.
For context, the concern on our side is not only the time taken when wp_mail() is actually called, but the broader runtime overhead we are seeing on a busy WooCommerce multisite environment and less busy standalone wp sites with minimal plugins. We found Post SMTP being worse in terms of performance the woocommerce itself. This includes plugin-related hooks, option access, logging/history features, and any work performed during normal frontend or AJAX requests.
Our environment is:
WordPress multisite & standalone WP installs
WooCommerce-enabled store(s) (Site 1 & 2)
Object cache enabled via Redis
Page caching enabled via LiteSpeed
New Relic monitoring in place
Versions/configuration:
WordPress: 6.9.4
PHP: 8.3.30
WooCommerce: 10.7.0
Post SMTP: Latest
Logging enabled: Yes
What we are trying to determine is whether any Post SMTP functionality is contributing measurable overhead outside of actual wp_mail() execution, particularly on frontend/admin-ajax requests in a plugin-heavy WooCommerce setup.
If helpful, I can provide (Via email or offline):
1. a list of active plugins on the affected sites
2. New Relic traces / timings
3. the specific Post SMTP features currently enabled
If there are any recommended settings for reducing runtime overhead in a high-traffic WooCommerce multisite setup (our primary concern), please let us know.
We have however now moved 16 sites of post SMTP so only have historical data only.Thanks. To be clear, this was observed on a live production site rather than an isolated test install, so I cannot yet give you a guaranteed single-click sandbox repro.
What I can give you is the exact plugin version, the failing code paths, the request endpoints, and the configuration conditions that make the issue reachable.
Plugin version:
conditional-extra-fees-for-woocommerce 1.1.49.42We have now seen two separate fatals in your plugin during WooCommerce Store API cart requests.
- Payment processing fee path
File:
public/class-apply-payment-processing-fee.php:28Code:
if (isset(WC()->session) && WC()->session->has_session()) {Failing request:
POST /wp-json/wc/store/v1/cart/add-itemFatal:
Call to undefined method Automattic\WooCommerce\StoreApi\SessionHandler::has_session()This path becomes reachable when:
- WooCommerce is recalculating cart fees during a Store API cart request, and
- the payment processing fee feature is enabled so
apply_gateway_fee()runs.
- Country rule path
File:
admin/selection_rules/rules/country.php:115Code:
$user_country = WC()->customer->get_shipping_country();Failing request:
GET /wp-json/wc/store/v1/cart?_locale=userFatal:
Call to a member function get_shipping_country() on nullThis path becomes reachable when:
- cart fees are calculated during a Store API cart/cart refresh request, and
- at least one fee rule uses the
Country/Continentcondition soPi_cefw_selection_rule_country->conditionCheck()runs.
So while I cannot yet provide a clean sandbox repro from our side, the expected reproduction setup on your side should be:
For the first issue:
- Fresh WooCommerce install.
- Activate only WooCommerce + Conditional Extra Fees for WooCommerce.
- Enable a payment processing fee rule so
Apply_Payment_Processing_Fee->apply_gateway_fee()is active. - Trigger Store API cart add-to-cart flow via
/wp-json/wc/store/v1/cart/add-item. - Observe whether
WC()->sessionis a Store API session handler on that request and whetherhas_session()is called.
For the second issue:
- Fresh WooCommerce install.
- Activate only WooCommerce + Conditional Extra Fees for WooCommerce.
- Create any fee rule using the
Country/Continentcondition. - Open the cart or trigger
/wp-json/wc/store/v1/cart?_locale=user. - Observe whether
WC()->customeris null whenconditionCheck()runs.
Even if you cannot reproduce immediately, both code paths currently assume classic WooCommerce objects are always available in Store API requests:
WC()->session->has_session()WC()->customer->get_shipping_country()
Those assumptions are what our production traces are failing on.
If helpful, I can also send the full stack traces for both errors.
We’ve now identified a second fatal in the same plugin during WooCommerce Store API cart requests.
This one occurs on:
GET /wp-json/wc/store/v1/cart?_locale=userFatal:
Call to a member function get_shipping_country() on nullFile:
admin/selection_rules/rules/country.php:115From the plugin code, the country rule does:
$user_country = WC()->customer->get_shipping_country();with no null check on
WC()->customer.Combined with the earlier fatal on:
WC()->session->has_session()during:
POST /wp-json/wc/store/v1/cart/add-itemthis suggests the plugin is assuming classic WooCommerce customer/session objects are always present during Store API requests.
WooCommerce’s Cart and Checkout blocks use the Store API for normal frontend cart activity, so these requests are part of expected customer browsing, not necessarily bot traffic. The issue appears to be that the plugin is not handling Store API contexts defensively.
At this point we have two separate Store API fatals in the plugin:
StoreApi\SessionHandler::has_session()WC()->customerbeing null in the country rule
That looks like a broader Store API compatibility issue rather than an isolated edge case.
Great, thank you. We’ll continue to test it but so far the performance benefit has been noticeable which is great.
Great, thank you !
A more fundamental improvement: when a gift card product’s delivery methods are email or downloadable only (no physical shipping option), the plugin should set the WooCommerce _virtual meta to ‘yes’ on the product. This lets WooCommerce core handle shipping exclusion natively via needs_shipping() — no filter needed at all.
The wc_shipping_enabled filter would then only be necessary for the edge case where a gift card offers a physical “Shipping” delivery method alongside digital options, and even then it should be cached as described above.
This could be implemented as:
- Automatically setting _virtual = ‘yes’ when a gift card product is created and only has digital delivery methods configured
- Updating the flag when delivery method settings change
- Documenting that store owners should mark digital-only gift cards as Virtual
On our end, we’ve marked our digital gift card product as Virtual and removed the filter via a code snippet, which resolved the performance issue completely. But most store owners won’t have profiling tools to identify this, so the plugin should handle it by default.
Thanks for checking.
I’ve gone back through the stack trace and there are two points that may help narrow this down.
The fatal is not occurring on the classic checkout flow. It is occurring during a Store API cart request on:
/wp-json/wc/store/v1/cart/add-itemIn our case, the call stack shows WooCommerce recalculating cart totals during that request, which then triggers your fee callback:
WC_Cart->calculate_fees()
→Apply_Payment_Processing_Fee->apply_gateway_fee()At that point,
WC()->sessionis an instance ofAutomattic\WooCommerce\StoreApi\SessionHandler, not the classicWC_Session_Handler. The fatal is specifically:Call to undefined method Automattic\WooCommerce\StoreApi\SessionHandler::has_session()So the immediate issue is not whether the endpoint exists, but whether the plugin assumes that
WC()->sessionalways exposes the classic handler methods during Store API / Blocks requests.For reference, WooCommerce currently has an open core bug describing the same problem in isolation, including the same
has_session()fatal when a Store API cart request is made and code callsWC()->session->has_session(). That report notes that the Store API session handler is not interface-compatible with the default session handler in this scenario. (GitHub)A few details that may explain why you are not seeing it consistently:
- It only appears when the plugin’s fee logic actually runs during cart recalculation on a Store API request.
- A traditional add-to-cart flow may not reproduce it, even if the product page uses modern WooCommerce components elsewhere.
- Reproduction is more reliable when testing against the real Blocks / Store API cart flow rather than just calling the endpoint in a way that does not reach the same fee path.
A minimal reproduction path on our side is:
- Activate WooCommerce and Conditional Extra Fees for WooCommerce.
- Ensure the fee logic is enabled in a way that causes
apply_gateway_fee()to run during cart totals calculation. - Add a product to cart through the Store API / Blocks flow so WooCommerce recalculates fees on
/wc/store/v1/cart/add-item. - The request reaches
apply_gateway_fee(), whereWC()->session->has_session()is called onAutomattic\WooCommerce\StoreApi\SessionHandler, producing the fatal above.
Based on the trace, the safe fix seems to be to avoid assuming
WC()->sessionalways supportshas_session()in Store API contexts, for example by adding a guard such asmethod_exists( WC()->session, 'has_session' )before calling it, or by using a Store API-safe approach that does not depend on that classic session handler method being present.If helpful, I can provide the exact stack trace and environment details from the site where this occurs via email/offline.
Looks to potentially fix it, just waiting to hear back from customer emails are tests show ok. !
Hello,
All of our templates have the modern block configured. After the WC update, all emails being sent for orders etc were using the WC default templates?
Toggling enable/disabled yaymail has fixed the issue for all but the new order dev/admin emails.Hello,
Someone else reported it on the last woocommerce update here: https://wordpress.org/support/topic/templates-get-removed-when-updating-woo/It seems toggling sorts some of the template but not all. Is there a fix for this ?
We’ve had to toggle on/off all templates to get them to work again. Seems other users have this issue also from other tickets.
Ok, so if this plugin breaks woocommerce stripe refunds (which is an official plugin) can you make clear its not compatible and therefor it should not be used?
We’ll have to remove this plugin because of this issue.Forum: Plugins
In reply to: [WooCommerce Stripe Payment Gateway] Address line1 validation fails since 9.7Hello,
Thank you for doing that, much appreciated.
We have followed up on the github ticket directly and adapted the reference into a workaround for review.