Message for non-discounted items
-
Hi, I wanted to put a message for non-discounted items.
I was thinking of using the following code
add_action( 'woocommerce_before_main_content', 'wp_test' ); function wp_test(){ global $product; if ( $product->is_on_sale() ) { echo 'Messaggio 1'; } else { echo 'Messaggio 2'; } }
however, I get the error
CRITICAL Uncaught Error: Call to a member function is_on_sale() on string
Can anyone give me some indication of what am I wrong?
Thank you
-
Hello,
More info abot this method can be found at:
https://woocommerce.github.io/code-reference/classes/WC-Product.html#method_is_on_saleTo check better into this please provide the following:
Please share a copy of your site’s System Status? You can find it via WooCommerce > Status. Select “Get system report” and then “Copy for support”.?
May I ask is this the only error message? Can you share a copy of any fatal error log found under WooCommerce > System Status > Logs (if any other error is visible).
Thanks for the reply.
here is the data
### WordPress Environment ### WordPress address (URL): https://www.pollicinokids.it Site address (URL): https://www.pollicinokids.it WC Version: 6.9.4 REST API Version: ? 6.9.4 WC Blocks Version: ? 8.3.3 Action Scheduler Version: ? 3.4.0 Log Directory Writable: ? WP Version: 6.0.2 WP Multisite: – WP Memory Limit: 1 GB WP Debug Mode: – WP Cron: ? Language: it_IT External object cache: – ### Server Environment ### Server Info: Apache PHP Version: 7.4.30 PHP Post Max Size: 128 MB PHP Time Limit: 900 PHP Max Input Vars: 1000 cURL Version: 7.76.1 OpenSSL/1.0.2k-fips SUHOSIN Installed: – MySQL Version: 5.7.35-38-log Max Upload Size: 128 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 6.9.4 WC Database Prefix: wpfn_ Dimensione totale database: 120.38MB Dimensione dati database: 83.63MB Dimensione indice database: 36.75MB wpfn_woocommerce_sessions: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_woocommerce_api_keys: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_woocommerce_attribute_taxonomies: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_woocommerce_downloadable_product_permissions: Dati: 0.02MB + indice: 0.06MB + motore InnoDB wpfn_woocommerce_order_items: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_woocommerce_order_itemmeta: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_woocommerce_tax_rates: Dati: 0.02MB + indice: 0.06MB + motore InnoDB wpfn_woocommerce_tax_rate_locations: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_woocommerce_shipping_zones: Dati: 0.02MB + indice: 0.00MB + motore InnoDB wpfn_woocommerce_shipping_zone_locations: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_woocommerce_shipping_zone_methods: Dati: 0.02MB + indice: 0.00MB + motore InnoDB wpfn_woocommerce_payment_tokens: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_woocommerce_payment_tokenmeta: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_woocommerce_log: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_actionscheduler_actions: Dati: 6.52MB + indice: 9.91MB + motore InnoDB wpfn_actionscheduler_claims: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_actionscheduler_groups: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_actionscheduler_logs: Dati: 4.52MB + indice: 4.02MB + motore InnoDB wpfn_commentmeta: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_comments: Dati: 0.02MB + indice: 0.09MB + motore InnoDB wpfn_e_events: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_links: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_mypos_pending_payments_schedule: Dati: 0.02MB + indice: 0.00MB + motore InnoDB wpfn_mypos_upsells: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_nextend2_image_storage: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_nextend2_section_storage: Dati: 0.02MB + indice: 0.06MB + motore InnoDB wpfn_nextend2_smartslider3_generators: Dati: 0.02MB + indice: 0.00MB + motore InnoDB wpfn_nextend2_smartslider3_sliders: Dati: 0.08MB + indice: 0.03MB + motore InnoDB wpfn_nextend2_smartslider3_sliders_xref: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_nextend2_smartslider3_slides: Dati: 0.11MB + indice: 0.11MB + motore InnoDB wpfn_options: Dati: 25.14MB + indice: 1.38MB + motore InnoDB wpfn_pimwick_gift_card: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_pimwick_gift_card_activity: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_postmeta: Dati: 27.20MB + indice: 13.11MB + motore InnoDB wpfn_posts: Dati: 13.13MB + indice: 2.58MB + motore InnoDB wpfn_revslider_css: Dati: 0.13MB + indice: 0.02MB + motore InnoDB wpfn_revslider_css_bkp: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_revslider_layer_animations: Dati: 0.02MB + indice: 0.00MB + motore InnoDB wpfn_revslider_layer_animations_bkp: Dati: 0.02MB + indice: 0.00MB + motore InnoDB wpfn_revslider_navigations: Dati: 0.02MB + indice: 0.00MB + motore InnoDB wpfn_revslider_navigations_bkp: Dati: 0.02MB + indice: 0.00MB + motore InnoDB wpfn_revslider_sliders: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_revslider_sliders_bkp: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_revslider_slides: Dati: 0.06MB + indice: 0.02MB + motore InnoDB wpfn_revslider_slides_bkp: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_revslider_static_slides: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_revslider_static_slides_bkp: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_termmeta: Dati: 0.13MB + indice: 0.11MB + motore InnoDB wpfn_terms: Dati: 0.08MB + indice: 0.06MB + motore InnoDB wpfn_term_relationships: Dati: 1.50MB + indice: 0.47MB + motore InnoDB wpfn_term_taxonomy: Dati: 0.08MB + indice: 0.06MB + motore InnoDB wpfn_usermeta: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_users: Dati: 0.02MB + indice: 0.05MB + motore InnoDB wpfn_wc_admin_notes: Dati: 0.06MB + indice: 0.00MB + motore InnoDB wpfn_wc_admin_note_actions: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_wc_category_lookup: Dati: 0.05MB + indice: 0.00MB + motore InnoDB wpfn_wc_customer_lookup: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_wc_download_log: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_wc_order_coupon_lookup: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_wc_order_product_lookup: Dati: 0.02MB + indice: 0.06MB + motore InnoDB wpfn_wc_order_stats: Dati: 0.02MB + indice: 0.05MB + motore InnoDB wpfn_wc_order_tax_lookup: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_wc_product_attributes_lookup: Dati: 1.47MB + indice: 1.36MB + motore InnoDB wpfn_wc_product_download_directories: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_wc_product_meta_lookup: Dati: 1.52MB + indice: 1.25MB + motore InnoDB wpfn_wc_rate_limits: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_wc_reserved_stock: Dati: 0.02MB + indice: 0.00MB + motore InnoDB wpfn_wc_tax_rate_classes: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_wc_webhooks: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_woodmart_wishlists: Dati: 0.02MB + indice: 0.00MB + motore InnoDB wpfn_woodmart_wishlist_products: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_yoast_indexable: Dati: 0.44MB + indice: 0.48MB + motore InnoDB wpfn_yoast_indexable_hierarchy: Dati: 0.27MB + indice: 0.42MB + motore InnoDB wpfn_yoast_migrations: Dati: 0.02MB + indice: 0.02MB + motore InnoDB wpfn_yoast_primary_term: Dati: 0.02MB + indice: 0.03MB + motore InnoDB wpfn_yoast_seo_links: Dati: 0.02MB + indice: 0.03MB + motore InnoDB ### Post Type Counts ### attachment: 3419 cms_block: 26 custom_css: 3 elementor_library: 1 mc4wp-form: 1 nav_menu_item: 88 page: 31 portfolio: 9 post: 7 product: 1214 product_variation: 5183 revision: 1756 shop_coupon: 17 woodmart_sidebar: 1 woodmart_size_guide: 1 wp_global_styles: 3 wpcf7_contact_form: 1 wpcf7r_action: 1 ### Security ### Secure connection (HTTPS): ? Hide errors from visitors: ? ### Active Plugins (25) ### Simple SEO: by David Cole – 1.8.12 Contact Form 7: by Takayuki Miyoshi – 5.6.3 Elementor: by Elementor.com – 3.7.7 Cookie and Consent Solution for the GDPR & ePrivacy: by iubenda – 3.2.3 Klarna On-Site Messaging for WooCommerce: by krokedil klarna – 1.8.0 Klarna Payments for WooCommerce: by krokedil klarna automattic – 2.11.5 Loco Translate: by Tim Whitlock – 2.6.2 MC4WP: Mailchimp for WordPress: by ibericode – 4.8.10 Woocommerce myPOS Checkout: by myPOS Europe LTD – 1.3.20 Password Protected: by WPExperts – 2.5.3 PW WooCommerce Gift Cards: by Pimwick LLC – 1.218 Slider Revolution: by ThemePunch – 6.5.31 Safe SVG: by 10up – 2.0.3 WC Hide Shipping Methods: by Rynaldo Stoltz – 1.5 WooCommerce Smart COD: by woosmartcod.com – 1.6.1 Return Refund and Exchange for WooCommerce: by WP Swings – 4.0.6 WooCommerce Satispay: by Satispay – 2.1.0 WooCommerce Conversion Tracking: by weDevs – 2.0.10 Print Invoice & Delivery Notes for WooCommerce: by Tyche Softwares – 4.6.5 Gift Wrapper Plus: by Sagehen Studio – 5.0-beta4 WooCommerce PayPal Payments: by WooCommerce – 1.9.3 WooCommerce: by Automattic – 6.9.4 Woodmart Core: by – 1.0.34 WPC Grouped Product for WooCommerce: by WPClever – 3.1.9 Redirection for Contact Form 7: by Qube One – 2.7.0 ### Inactive Plugins (0) ### ### Settings ### API Enabled: ? Force SSL: – Currency: EUR (€) Currency Position: right_space Thousand Separator: . Decimal Separator: , Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) pw gift card (pw-gift-card) simple (simple) variable (variable) woosg (woosg) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: ? Enforce Approved Product Download Directories: – ### WC Pages ### Shop base: #613 - /shop/ Carrello: #614 - /cart/ Pagamento: #615 - /checkout/ Il mio account: ? La visibilità della pagina dovrebbe essere pubblica Termini e condizioni: #812 - /termini-e-condizioni/ ### Theme ### Name: Woodmart Child Version: 1.0.0 Author URL: https://xtemos.com Child Theme: ? Parent Theme Name: Woodmart Parent Theme Version: 6.5.4 Parent Theme Author URL: https://www.cartoleriafavia.com WooCommerce Support: ? ### Templates ### Overrides: woodmart/woocommerce/archive-product.php woodmart/woocommerce/cart/cart-item-data.php woodmart/woocommerce/cart/cart.php woodmart/woocommerce/cart/cross-sells.php woodmart/woocommerce/cart/mini-cart.php woodmart/woocommerce/checkout/form-checkout.php woodmart/woocommerce/checkout/thankyou.php woodmart/woocommerce/content-product-cat.php woodmart/woocommerce/content-product.php woodmart/woocommerce/content-single-product.php woodmart/woocommerce/content-widget-product.php woodmart/woocommerce/global/breadcrumb.php woodmart/woocommerce/global/form-login.php woodmart/woocommerce/global/quantity-input.php woodmart/woocommerce/loop/add-to-cart.php woodmart/woocommerce/loop/loop-end.php woodmart/woocommerce/loop/loop-start.php woodmart/woocommerce/loop/no-products-found.php woodmart/woocommerce/loop/orderby.php woodmart/woocommerce/loop/pagination.php woodmart/woocommerce/loop/sale-flash.php woodmart/woocommerce/myaccount/form-login.php versione 4.1.0 è obsoleta. La versione attuale è 6.0.0 woodmart/woocommerce/product-searchform.php woodmart/woocommerce/single-product/add-to-cart/grouped.php woodmart/woocommerce/single-product/add-to-cart/variable.php woodmart/woocommerce/single-product/meta.php woodmart/woocommerce/single-product/product-attributes.php woodmart/woocommerce/single-product/product-image.php woodmart/woocommerce/single-product/product-thumbnails.php woodmart/woocommerce/single-product/rating.php woodmart/woocommerce/single-product/related.php woodmart/woocommerce/single-product/sale-flash.php woodmart/woocommerce/single-product/tabs/description.php woodmart/woocommerce/single-product/tabs/tabs.php woodmart/woocommerce/single-product/title.php woodmart/woocommerce/single-product/up-sells.php woodmart/woocommerce/single-product.php Outdated Templates: ? Scopri come aggiornare ### Klarna Payments Request Log ### 2022-09-19 10:45:15: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:45:14: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:45:10: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:45:10: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:45:10: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:45:09: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:39:30: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:39:30: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:39:25: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:39:24: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:39:24: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-09-19 10:39:24: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-08-04 12:35:27: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-08-04 12:35:27: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: 2022-08-04 12:35:24: KP Create Session Response code: 401 Response message: {"headers":[],"body":"<html><head><title>401 Authorization Required<\/title><\/head><body><center><h1>401 Authorization Required<\/h1><\/center><\/body><\/html>","response":{"code":401,"message":"Unauthorized"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}} Correlation ID: ### Klarna Countries ### Production Countries: IT Test Countries: No countries selected ### WooCommerce PayPal Payments ### Onboarded: ? Shop country code: IT WooCommerce currency supported: ? PayPal card processing available in country: ? Pay Later messaging available in country: ? Webhook status: – Vault enabled: ? Logging enabled: – Reference Transactions: ? Used PayPal Checkout plugin: – Tracking enabled: ? ### Admin ### Enabled Features: activity-panels analytics coupons customer-effort-score-tracks experimental-products-task experimental-import-products-task experimental-fashion-sample-products experimental-product-tour shipping-smart-defaults shipping-setting-tour homescreen marketing mobile-app-banner navigation onboarding onboarding-tasks remote-inbox-notifications remote-free-extensions payment-gateway-suggestions shipping-label-banner subscriptions store-alerts transient-notices wc-pay-promotion wc-pay-welcome-page Disabled Features: minified-js new-product-management-experience settings Daily Cron: ? Next scheduled: 2022-10-03 13:17:27 +02:00 Options: ? Notes: 75 Onboarding: completed ### Action Scheduler ### Completato: 21.829 Oldest: 2022-09-02 16:09:17 +0200 Newest: 2022-10-03 10:19:58 +0200 Operazione non riuscita: 1 Oldest: 2022-07-14 13:45:35 +0200 Newest: 2022-07-14 13:45:35 +0200 In attesa: 1 Oldest: 2022-10-03 18:48:05 +0200 Newest: 2022-10-03 18:48:05 +0200 ### Status report information ### Generated at: 2022-10-03 10:19:59 +02:00
these are the errors in the logs. Keep in mind that I have done a lot of tests with different code
2022-09-30T09:23:11+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:230 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #5 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #7 {main} thrown in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 230 2022-09-30T09:23:47+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:228 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php(238): the_dramatist_price_show() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #3 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #5 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #7 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #8 in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 228 2022-09-30T09:24:21+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:228 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php(238): the_dramatist_price_show() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #3 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #5 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #7 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #8 in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 228 2022-09-30T09:25:01+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:228 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php(237): the_dramatist_price_show() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #3 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #5 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #7 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #8 in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 228 2022-09-30T09:26:23+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:228 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php(237): the_dramatist_price_show() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #3 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #5 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #7 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #8 in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 228 2022-09-30T09:26:30+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:228 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php(237): the_dramatist_price_show() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #3 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #5 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #7 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #8 in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 228 2022-09-30T09:31:56+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:239 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #5 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #7 {main} thrown in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 239 2022-09-30T09:35:11+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:239 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #5 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #7 {main} thrown in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 239 2022-09-30T09:36:56+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on bool in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:245 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #5 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #7 {main} thrown in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 245 2022-09-30T09:37:21+00:00 CRITICAL Uncaught Error: Call to a member function get_type() on bool in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:233 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #5 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #7 {main} thrown in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 233 2022-09-30T09:37:48+00:00 CRITICAL Uncaught Error: Call to a member function get_type() on bool in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:233 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #5 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #7 {main} thrown in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 233 2022-09-30T09:38:52+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:235 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #5 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #7 {main} thrown in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 235 2022-09-30T09:41:28+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:230 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #5 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #7 {main} thrown in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 230 2022-09-30T09:41:34+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:230 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #5 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #7 {main} thrown in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 230 2022-09-30T09:47:22+00:00 CRITICAL Uncaught Error: Call to a member function get_attributes() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.php:1405 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php(231): woodmart_get_product_attributes_label() #1 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php(246): woodmart_product_label() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #5 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #6 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #7 /web/htdocs/www.pollic in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.php alla riga 1405 2022-09-30T09:48:31+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:229 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php(241): woodmart_product_labelXX() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #3 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #5 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #7 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #8 in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 229 2022-09-30T09:49:22+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:229 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php(242): woodmart_product_labelXX() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_kama_woocommerce_before_main_content_action() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #3 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #5 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #7 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #8 in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 229 2022-09-30T10:04:50+00:00 CRITICAL Uncaught Error: Call to a member function is_on_sale() on string in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php:231 Stack trace: #0 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(307): wp_test() #1 /web/htdocs/www.pollicinokids.it/home/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #2 /web/htdocs/www.pollicinokids.it/home/wp-includes/plugin.php(476): WP_Hook->do_action() #3 /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart/woocommerce/single-product.php(23): do_action() #4 /web/htdocs/www.pollicinokids.it/home/wp-includes/template-loader.php(106): include('/web/htdocs/www...') #5 /web/htdocs/www.pollicinokids.it/home/wp-blog-header.php(19): require_once('/web/htdocs/www...') #6 /web/htdocs/www.pollicinokids.it/home/index.php(17): require('/web/htdocs/www...') #7 {main} thrown in /web/htdocs/www.pollicinokids.it/home/wp-content/themes/woodmart-child/functions.php alla riga 231
Hello,
Thanks for the report.May I ask does this code work for you?
function test() { $sale_items = wc_get_product_ids_on_sale(); if ( empty( $sale_items ) ) { error_log('There are no sale items.'); } else { error_log('There is at least one sale item.'); } } add_action( 'wp_footer', 'test' );
[Source].
I changed the function to write in the footer.
function test() { $sale_items = wc_get_product_ids_on_sale(); if ( empty( $sale_items ) ) { echo 'There are no sale items.'; } else { echo 'There is at least one sale item.'; } } add_action( 'wp_footer', 'test' );
No error is generated but it always finds me “There is at least one sale item.”
Hi @pyramidba
No error is generated but it always finds me “There is at least one sale item.”
Can you further elaborate on what you mean here?
I tested the code on my site and it is working fine on my end.
When there are no products on sale, I can see the correct message below:
Image Link: https://snipboard.io/h6wtZC.jpg
Sorry for the delay.
I meant on any page of the site I go (contact / registration / etc) it still displays “There is at least one sale item.”
However, this does not help me. I don’t need to have the information in the footer but in “woocommerce_before_main_content” because I have to print a message on the screen
Hi @pyramidba
I understand that you want to display a custom message on your site for non-discounted items.
These forums are meant for general support with the core functionality of WooCommerce itself. What you want to achieve would require customization to do it. Since custom coding is outside our scope of support, I am leaving this thread open for a bit to see if anyone can chime in to help you out.
For questions related to development and custom coding, your best bet is to ask on any of these channels for support. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.
– WooCommerce Developer Resources Portal
– WooCommerce Advanced Facebook group
– WooCommerce Community Forum
– WooCommerce Developer Slack Channel.
– Hire a WooCommerce Expert
- The topic ‘Message for non-discounted items’ is closed to new replies.