Need help choosing hook for cart counter
-
First, our domain is test.druthers.ca (checkout page.)
Here’s the status report from WooCommerce:
### WordPress Environment ### WordPress address (URL): https://test.druthers.ca Site address (URL): https://test.druthers.ca WC Version: 8.7.0 REST API Version: ? 8.7.0 Action Scheduler Version: ? 3.7.2 Log Directory Writable: ? WP Version: 6.5 WP Multisite: – WP Memory Limit: 640 MB WP Debug Mode: ? WP Cron: ? Language: en_US External object cache: – ### Server Environment ### Server Info: Apache PHP Version: 8.2.16 PHP Post Max Size: 50 MB PHP Time Limit: 180 PHP Max Input Vars: 10000 cURL Version: 7.74.0 OpenSSL/1.1.1k SUHOSIN Installed: – MySQL Version: 10.4.17-MariaDB-1:10.4.17+maria~jessie-log Max Upload Size: 50 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 8.7.0 WC Database Prefix: wp_x9jn3m Total Database Size: 502.75MB Database Data Size: 247.04MB Database Index Size: 255.71MB wp_x9jn3mwoocommerce_sessions: Data: 0.03MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwoocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwoocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwoocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_x9jn3mwoocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwoocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwoocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_x9jn3mwoocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwoocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3mwoocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwoocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3mwoocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwoocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwoocommerce_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mactionscheduler_actions: Data: 3.52MB + Index: 2.47MB + Engine InnoDB wp_x9jn3mactionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mactionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mactionscheduler_logs: Data: 2.52MB + Index: 1.94MB + Engine InnoDB wp_x9jn3maiowps_audit_log: Data: 10.52MB + Index: 0.34MB + Engine InnoDB wp_x9jn3maiowps_debug_log: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3maiowps_events: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3maiowps_global_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3maiowps_logged_in_users: Data: 0.02MB + Index: 0.08MB + Engine InnoDB wp_x9jn3maiowps_login_lockdown: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_x9jn3maiowps_message_store: Data: 1.52MB + Index: 0.00MB + Engine InnoDB wp_x9jn3maiowps_permanent_block: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mawb_critical_css: Data: 4.52MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mcommentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mcomments: Data: 58.59MB + Index: 61.13MB + Engine InnoDB wp_x9jn3mfusion_forms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mfusion_form_entries: Data: 0.03MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mfusion_form_fields: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mfusion_form_submissions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mlinks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3moptions: Data: 5.44MB + Index: 0.11MB + Engine InnoDB wp_x9jn3mpostmeta: Data: 145.70MB + Index: 183.53MB + Engine InnoDB wp_x9jn3mposts: Data: 10.52MB + Index: 0.69MB + Engine InnoDB wp_x9jn3mslim_seo_404: Data: 2.52MB + Index: 3.55MB + Engine InnoDB wp_x9jn3mtermmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mterms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mterm_relationships: Data: 0.17MB + Index: 0.16MB + Engine InnoDB wp_x9jn3mterm_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3musermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3musers: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_x9jn3mwcs_payment_retries: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwc_admin_notes: Data: 0.08MB + Index: 0.00MB + Engine InnoDB wp_x9jn3mwc_admin_note_actions: Data: 0.06MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3mwc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwc_orders: Data: 0.02MB + Index: 0.13MB + Engine InnoDB wp_x9jn3mwc_orders_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwc_order_addresses: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_x9jn3mwc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwc_order_operational_data: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_x9jn3mwc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_x9jn3mwc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_x9jn3mwc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwc_product_meta_lookup: Data: 0.11MB + Index: 0.27MB + Engine InnoDB wp_x9jn3mwc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3mwc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_x9jn3mwpmailsmtp_debug_events: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3mwpmailsmtp_tasks_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3mwt_iew_action_history: Data: 0.11MB + Index: 0.00MB + Engine InnoDB wp_x9jn3mwt_iew_cron: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3mwt_iew_ftp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_x9jn3mwt_iew_mapping_template: Data: 0.02MB + Index: 0.00MB + Engine InnoDB ### Post Type Counts ### attachment: 1352 avada_faq: 16 awb_off_canvas: 4 fusion_element: 15 fusion_form: 2 fusion_tb_layout: 8 fusion_tb_section: 14 nav_menu_item: 78 page: 23 post: 671 product: 37 product_variation: 500 revision: 37 shop_coupon: 7 shop_order: 1 shop_order_refund: 479 shortcoder: 1 status_automation: 1 ywsbs_subscription: 1 ### Security ### Secure connection (HTTPS): ? Hide errors from visitors: ? ### Active Plugins (16) ### All In One WP Security: by All In One WP Security & Firewall Team – 5.2.9 Classic Editor: by WordPress Contributors – 1.6.3 Donorbox Donation Form: by rebelidealist – 7.1.9 Enable Media Replace: by ShortPixel – 4.1.5 Envato Market: by Envato – 2.0.11 Avada Builder: by ThemeFusion – 3.11.7 Avada Core: by ThemeFusion – 5.11.7 Avada Custom Branding: by ThemeFusion – 1.2 Heartbeat Control by WP Rocket: by WP Rocket – 2.0.1 Shortcoder: by Aakash Chakravarthy – 6.3.2 Slim SEO Schema: by eLightUp – 2.4.2 Slim SEO: by eLightUp – 3.23.2 Woo Subscriptions: by WooCommerce – 6.1.0 WooCommerce: by Automattic – 8.7.0 WP Mail SMTP: by WP Mail SMTP – 4.0.1 WP-Sweep: by Lester 'GaMerZ' Chan – 1.1.8 ### Inactive Plugins (8) ### Simple Shipping Labels for WooCommerce: by Dima Pavlenko – 1.0.7 W3 Total Cache: by BoldGrid – 2.7.1 WooCommerce Dynamic Pricing & Discounts: by RightPress – 2.4.6 WooCommerce PayPal Payments: by WooCommerce – 2.6.0 WooCommerce Print Order List: by WP Overnight – 2.0.1 WooCommerce Stripe Gateway: by WooCommerce – 8.1.1 WooCommerce Subscriptions - Preserve Billing Schedule: by Prospress Inc. – 1.0.0 WPC Order Notes for WooCommerce: by WPClever – 1.4.9 ### Settings ### API Enabled: – Force SSL: – Currency: CAD ($) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) variable (variable) variable-subscription (variable-subscription) 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 Woo.com: ? Enforce Approved Product Download Directories: ? HPOS feature screen enabled: ? HPOS feature enabled: ? Order datastore: Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore HPOS data sync enabled: ? ### Logging ### Enabled: ? Handler: Automattic\WooCommerce\Internal\Admin\Logging\LogHandlerFileV2 Retention period: 30 days Level threshold: – Log directory size: 98 MB ### WC Pages ### Shop base: #205809 - /shop/ Cart: #173362 - /cart/ Checkout: ? Page does not contain the [woocommerce_checkout] shortcode or the woocommerce/checkout block. My account: #9 - /my-account/ Terms and conditions: ? Page not set ### Theme ### Name: Druthers Version: 202404071943h Author URL: https://laughlinweb.net Child Theme: ? Parent Theme Name: Avada Parent Theme Version: 7.11.7 Parent Theme Author URL: https://themeforest.net/user/ThemeFusion WooCommerce Support: ? ### Templates ### Overrides: Avada/woocommerce/cart/cart.php Avada/woocommerce/checkout/form-pay.php Avada/woocommerce/checkout/review-order.php Avada/woocommerce/single-product/short-description.php Avada/woocommerce/single-product/tabs/additional-information.php Avada/woocommerce/single-product/tabs/description.php ### Subscriptions ### WCS_DEBUG: ? No Subscriptions Mode: ? Staging Subscriptions Live URL: https://druthers.ca Subscriptions-core Library Version: 6.9.0 Subscription Statuses: – WooCommerce Account Connected: ? Yes Active Product Key: ? Yes Custom Retry Rules: ? Yes Custom Retry Rule Class: ? No Custom Raw Retry Rule: ? No Custom Retry Rule: ? No Retries Migration Status: ? Completed Report Cache Enabled: ? Yes Cache Update Failures: ? 0 failure ### Store Setup ### Country / State: Canada — Ontario ### Subscriptions by Payment Gateway ### ### Payment Gateway Support ### Check payments: products ### Admin ### Enabled Features: activity-panels analytics product-block-editor coupons core-profiler customer-effort-score-tracks import-products-task experimental-fashion-sample-products shipping-smart-defaults shipping-setting-tour homescreen marketing mobile-app-banner navigation onboarding onboarding-tasks product-variation-management product-virtual-downloadable product-external-affiliate product-grouped product-linked remote-inbox-notifications remote-free-extensions payment-gateway-suggestions shipping-label-banner subscriptions store-alerts transient-notices woo-mobile-welcome wc-pay-promotion wc-pay-welcome-page Disabled Features: customize-store minified-js new-product-management-experience product-pre-publish-modal settings async-product-editor-category-field Daily Cron: ? Next scheduled: 2024-04-09 00:05:40 -04:00 Options: ? Notes: 109 Onboarding: completed ### Action Scheduler ### Complete: 5,684 Oldest: 2024-03-08 09:17:10 -0500 Newest: 2024-04-08 09:16:59 -0400 Failed: 243 Oldest: 2023-07-25 23:41:00 -0400 Newest: 2024-04-08 09:18:28 -0400 Pending: 2,232 Oldest: 2024-04-08 10:08:23 -0400 Newest: 2025-06-10 13:07:26 -0400 ### Status report information ### Generated at: 2024-04-08 09:31:26 -04:00
I’ve used the following code to create a cart items counter for display on the front-end:
//Visually provide the cart total from within the nav manu item function druthers_cart_counter() { if (is_single() || is_page() || (is_product() && !is_admin()) || (is_shop() && !is_admin())) { global $woocommerce; $cartcount = $woocommerce->cart->get_cart_contents_count(); echo '<span id="druthers-cart-count" style="display:none;">'.$cartcount.'</span>'; } } add_action('wp', 'druthers_cart_counter', 99 );
I’ve been advised that wp was a very poor choice of hook, as it has broken the checkout process (payment interface is grayed out.)
I was told to use a woocommerce specific hook – but after skimming the list at https://woocommerce.github.io/code-reference/hooks/hooks.html I have to say I’m overwhelmed, there is such a plethora of options.
Any pointers would be invaluable, thanks for reading.
The page I need help with: [log in to see the link]
- The topic ‘Need help choosing hook for cart counter’ is closed to new replies.