woocommerce / woocommerce-blocks

(Deprecated) This plugin has been merged into woocommerce/woocommerce
https://wordpress.org/plugins/woo-gutenberg-products-block/
GNU General Public License v3.0
403 stars 218 forks source link

Cannot modify the AllProducts Block via woocommerce_blocks_product_grid_item_html filter #1714

Closed nerrad closed 4 years ago

nerrad commented 4 years ago

@helgatheviking commented on Fri Feb 07 2020

Describe the bug A clear and concise description of what the bug is. Please be as descriptive as possible; issues lacking detail, or for any other reason than to report a bug, may be closed without action.

To Reproduce Steps to reproduce the behavior: Add this snippet to functions.php

/**
 * Customize block product layout
 * @param  string $html
 * @param  obj $data
 * @param  WC_Product $product
 * @return string
 */
function kia_customize_block_product( $html, $data, $product ) {
    $html = "<li class=\"wc-block-grid__product\">
                <a href=\"{$data->permalink}\" class=\"wc-block-grid__product-link\">
                    {$data->image}
                    {$data->title}
                </a>
                <p>Tacos are great!</p>
                {$data->badge}
                {$data->price}
                {$data->rating}
                {$data->button}
            </li>";
    return $html;
}
add_filter( 'woocommerce_blocks_product_grid_item_html', 'kia_customize_block_product', 10, 3 );

And then create two blocks on a page. One "Products by category" block and then the "All products" block.

Save and view the page on the front end.

"Tacos are great!" should appear underneath the product title in the "Products from Category" block, but not in the "All Products" block.

Screenshots ![front end display of both blocks…]()

Expected behavior I expect the woocommerce_blocks_product_grid_item_html filtered content to appear in the All products block.

Isolating the problem (mark completed items with an [x]):

WordPress Environment

``` ` ### WordPress Environment ### WordPress address (URL): http://sandbox.test Site address (URL): http://sandbox.test WC Version: 3.9.0 REST API Version: ✔ 1.0.5 Log Directory Writable: ✔ WP Version: 5.3.2 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: ✔ WP Cron: ✔ Language: en_US External object cache: – ### Server Environment ### Server Info: nginx/1.16.0 PHP Version: 7.3.5 PHP Post Max Size: 1,000 MB PHP Time Limit: 1200 PHP Max Input Vars: 4000 cURL Version: 7.64.0 OpenSSL/1.1.1b SUHOSIN Installed: – MySQL Version: 8.0.16 Max Upload Size: 300 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 3.9.0 WC Database Prefix: wp_ Total Database Size: 13.56MB Database Data Size: 8.97MB Database Index Size: 4.59MB wp_woocommerce_sessions: Data: 0.11MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_order_itemmeta: Data: 0.08MB + Index: 0.09MB + Engine InnoDB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_log: Data: 1.50MB + Index: 0.11MB + Engine InnoDB wp_actionscheduler_actions: Data: 0.05MB + Index: 0.11MB + Engine InnoDB wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_logs: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 0.05MB + Index: 0.09MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_options: Data: 4.03MB + Index: 0.06MB + Engine InnoDB wp_postmeta: Data: 2.36MB + Index: 3.17MB + Engine InnoDB wp_posts: Data: 0.14MB + Index: 0.06MB + Engine InnoDB wp_simple_auction_log: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_um_metadata: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_usermeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_bundled_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_bundled_items: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_square_customers: Data: 0.02MB + Index: 0.00MB + Engine InnoDB ### Post Type Counts ### attachment: 53 customize_changeset: 7 global_product_addon: 2 nav_menu_item: 4 page: 19 post: 4 product: 70 product_variation: 44 revision: 40 shop_coupon: 2 shop_order: 26 shop_subscription: 12 tribe_events: 1 tribe_venue: 1 um_directory: 1 um_form: 3 ### Security ### Secure connection (HTTPS): ❌ Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates. Hide errors from visitors: ❌Error messages should not be shown to visitors. ### Active Plugins (1) ### WooCommerce: by Automattic – 3.9.0 – 3.9.1 is available ### Inactive Plugins (191) ### aaa-test-guten-block — CGB Gutenberg Block Plugin: by mrahmadawais maedahbatool – 1.0.0 Add to Cart Form Shortcode for WooCommerce: by helgatheviking – 3.0.0 – Not tested with the active version of WooCommerce Advanced Custom Fields: by Elliot Condon – 5.8.7 Aelia Currency Switcher for WooCommerce: by Aelia – 4.7.6.190703 – Not tested with the active version of WooCommerce Aelia Foundation Classes for WooCommerce: by Aelia – 2.0.4.190201 – Not tested with the active version of WooCommerce Afterlife Custom Functions: by Kathy Darling – 0.1.0 Airplane Mode: by Andrew Norcross – 0.2.5 Akismet Anti-Spam: by Automattic – 4.1.3 AWeber for WordPress: by AWeber – 3.1.3 Beaver Builder Plugin (Pro Version): by The Beaver Builder Team – 2.1.2.2 Beaver Themer: by The Beaver Builder Team – 1.0.2.1 Bookings Helper: by WooCommerce – 1.0.2 – Not tested with the active version of WooCommerce Braintree For WooCommerce: by Payment Plugins support@paymentplugins.com – 3.1.3 Bulk remove posts from category: by MasterNs – 2.1 Catalog Product for WooCommerce: by Kathy Darling – 0.1.0 – Not tested with the active version of WooCommerce Change Taxonomy Buttons: by Moove Agency – 1.3.1 Common TinyMCE Styles: by Kathy Darling – 1.0.0 Debug: by SoniNow Team – 1.9 Debug Bar: by wordpressdotorg – 1.0 Debug Bar Slow Actions: by Konstantin Kovshenin – 0.8.4 Disable Google Fonts: by Milan Dinić – 2.0 Documentate: by helgatheviking – 0.1-beta Doc Validation for WooCommerce: by helgatheviking – 0.1.0 – Not tested with the active version of WooCommerce Easy Pricing Tables by Fatcat Apps: by Fatcat Apps – 2.4.4 Easy Pricing Tables Premium: Business: by Fatcat Apps – 2.3.10 Event Tickets: by Modern Tribe Inc. – 4.11.2 Event Tickets Plus: by Modern Tribe Inc. – 4.10.10 Featured Item Metabox: by Kathy Darling – 1.3.2 Front End Users: by Etoile Web Design – 3.2.6 Fusion Builder: by ThemeFusion – 1.7.2 Fusion Core: by ThemeFusion – 3.7.2 Generate Sections: by Tom Usborne – 1.0.28 Germanized for WooCommerce: by Vendidero – 3.1.2 Gutenberg: by Gutenberg Team – 7.4.0 Hello Gutenberg: by Hardeep Asrani – 1.0.0 Infinite Scroll for Admin: by Kathy Darling – 1.0.1 Invoices for WooCommerce: by Kathy Darling – 1.0.0.beta.3 – Not tested with the active version of WooCommerce KIA Subtitle: by Kathy Darling – 2.0.0 KIA Subtitle + WooCommerce Bridge: by Kathy Darling – 1.1.0 – Not tested with the active version of WooCommerce Local Always Authorize Me for API: by Kathy Darling – 1.0.0 Loco Translate: by Tim Whitlock – 2.3.1 Mailchimp for WooCommerce: by Mailchimp – 2.3.1 – Not tested with the active version of WooCommerce Nav Menu Roles: by Kathy Darling – 1.9.5 Nav Menu Roles + Restrict Content Pro Bridge: by Kathy Darling – 1.0.0 Nav Menu Roles + Wishlists Memberships Bridge: by Kathy Darling – 1.0.0 Nav Menu Roles + WooCommerce Memberships Bridge: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce Nav Menu Roles + WooCommerce Memberships Bridge: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce Nav Menu Roles Toggle: by helgatheviking – 0.1.0 Ninja Forms: by Saturday Drive – 3.4.22.1 Ninja Forms - AWeber: by Kathy Darling – 3.1.2 Ninja Forms - Mail Chimp: by The WP Ninjas – 3.1.7 Ninja Forms - Stripe: by The WP Ninjas – 3.0.18 Offers for WooCommerce: by Angell EYE – 1.4.14 – Not tested with the active version of WooCommerce Only Item in WooCommerce Cart: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce Plugin Toggle: by Cedaro – 1.3.1 Polylang: by WP SYNTEX – 2.6.9 Product Label Gallery for WooCommerce: by helgatheviking – 1.0.0-beta – Not tested with the active version of WooCommerce Projects Customized for Gael Bruno: by Kathy Darling – 1.1 Quantities and Units for WooCommerce: by Nicholas Verwymeren – 1.0.13 – Not tested with the active version of WooCommerce Radio Buttons for Taxonomies: by helgatheviking – 2.0.3 Remove crazy counts slowing down my dashboard: by Patrick Garman – 1.0.0 Restrict Content Pro: by Restrict Content Pro Team – 2.9.12 Role Based Prices for WooCommerce: by MarketPress – 2.0.10 – Not tested with the active version of WooCommerce Sample Customizable Product Field for WooCommerce: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce Sample Repeating Metaboxes: by helgatheviking – 1.0 Shipping Tracking Number for WooCommerce: by Kathy Darling – 1.0 – Not tested with the active version of WooCommerce Shortcodes Ultimate: by Vladimir Anokhin – 5.7.0 simple-user-listing-block — CGB Gutenberg Block Plugin: by mrahmadawais maedahbatool – 1.0.0 Simple User Listing: by Kathy Darling – 1.8.4 Snappic Integration for WooCommerce: by Snappic – 1.1.0 – Not tested with the active version of WooCommerce Storefront Powerpack: by WooCommerce – 1.4.9 Swift Framework: by Swift Ideas – 2.5.53 Test Ajax Email: by helgatheviking – 0.1 Test wpmu_delete_user: by Kathy Darling – 1.0.0 The Events Calendar: by Modern Tribe Inc. – 5.0.0.2 Theme and plugin translation for Polylang (TTfP): by Marcin Kazmierski – 3.2.2 Transients Manager: by Pippin Williamson – 1.8 Ultimate Member: by Ultimate Member – 2.1.3 User Switching: by John Blackbourn & contributors – 1.5.3 Variation Swatches for WooCommerce: by Emran Ahmed – 1.0.74 WC Coupon Redemption Form Shortcode: by Kathy Darling – 1.0.0 WC Custom quantity counter for Mix and Match: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WC Custom quantity counter for Mix and Match: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WC Empty Cart Coupons: by Kathy Darling – 1.0.0 WC Just Uno Integration: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WC Mix and Match + PIP: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WC Name Your Price + Aelia Currency Converter Bridge: by Kathy Darling – 0.3.0 – Not tested with the active version of WooCommerce WC Name Your Price - Done Typing: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WC Sample Background Update: by Kathy Darling – 1.0.0 WC Variable NYP + Product Bundles compat: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce What is slow: by Viper007Bond – 0.4 WooCommerce - ShipStation Integration: by WooCommerce – 4.1.29 – Not tested with the active version of WooCommerce WooCommerce Account Funds: by WooCommerce – 2.1.10 – Not tested with the active version of WooCommerce Woocommerce Add to cart Ajax for variable products: by Rishi Mehta - Rcreators Websolutions – 1.4 – Not tested with the active version of WooCommerce WooCommerce Admin Bar Addition: by David Decker - DECKERWEB – 2.7.0 – Not tested with the active version of WooCommerce WooCommerce All Products For Subscriptions: by SomewhereWarm – 3.0.1 WooCommerce AWeber Newsletter Subscription: by WooCommerce – 2.0.2 – Not tested with the active version of WooCommerce WooCommerce Blocks: by Automattic – 2.5.11 – Not tested with the active version of WooCommerce WooCommerce Bookings: by WooCommerce – 1.13.3 – Not tested with the active version of WooCommerce WooCommerce Bundle Style Coupons: by Coen Jacobs – 0.2 – Not tested with the active version of WooCommerce WooCommerce Composite Products: by SomewhereWarm – 5.1.3 – Not tested with the active version of WooCommerce WooCommerce Currency Switcher - Bundles Integration: by Aelia – 1.2.3.171201 – Not tested with the active version of WooCommerce WooCommerce Currency Switcher - Mix and Match Products Integration: by Aelia – 1.2.3.171201 – Not tested with the active version of WooCommerce WooCommerce Customizer: by SkyVerge – 2.7.2 WooCommerce Dealer Number: by Kathy Darling – 1.2.0 – Not tested with the active version of WooCommerce WooCommerce Default Quantity: by Barn2 Media – 1.0.2 – Not tested with the active version of WooCommerce WooCommerce Disable USPS Ground Shipping: by Kathy Darling – 1.0 – Not tested with the active version of WooCommerce WooCommerce Donations: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce Donations: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce Dummy Payments Gateway: by SomewhereWarm – 1.0.1 – Not tested with the active version of WooCommerce WooCommerce Dynamic Pricing: by Lucas Stark – 3.1.13 – Not tested with the active version of WooCommerce WooCommerce Extended Coupon Features FREE: by Soft79 – 3.1.2 – Not tested with the active version of WooCommerce WooCommerce Free Gift Coupons: by Kathy Darling – 2.4.2 WooCommerce Free Gift Coupons: Sync to Required Products: by Kathy Darling – 1.0.0.beta.1 – Not tested with the active version of WooCommerce WooCommerce Gift Coupon: by Alberto Pérez – 3.3.0 – Not tested with the active version of WooCommerce WooCommerce Local Pickup Plus: by SkyVerge – 2.5.2 – Not tested with the active version of WooCommerce WooCommerce Measurement Price Calculator: by SkyVerge – 3.13.3 – Not tested with the active version of WooCommerce WooCommerce Memberships: by SkyVerge – 1.13.0 – Not tested with the active version of WooCommerce WooCommerce Min/Max Quantities: by WooCommerce – 2.4.10 – Not tested with the active version of WooCommerce WooCommerce Mix and Match + Product Add-ons Bridge: by Kathy Darling – 1.0.0-beta – Not tested with the active version of WooCommerce WooCommerce Mix and Match: All Products for Subscriptions Bridge: by Kathy Darling – 1.0.4 – Not tested with the active version of WooCommerce WooCommerce Mix and Match: By Weight: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce Mix and Match: Categories: by Kathy Darling – 1.0.0-rc-2 – Not tested with the active version of WooCommerce WooCommerce Mix and Match: Checkboxes: by Kathy Darling – 1.1.0 – Not tested with the active version of WooCommerce WooCommerce Mix and Match: Grid Layout for Flatsome: by Kathy Darling – 1.0.0-beta-1 – Not tested with the active version of WooCommerce WooCommerce Mix and Match: Isotope Filter: by Kathy Darling – 1.0.0.beta.1 – Not tested with the active version of WooCommerce WooCommerce Mix and Match: Mobile Styles: by Kathy Darling – 1.0.0-beta-2 – Not tested with the active version of WooCommerce WooCommerce Mix and Match: Not Sold Separately: by Kathy Darling – 1.0.0-beta-1 WooCommerce Mix and Match: Per-Item Discount: by Kathy Darling – 1.0.0-beta-1 – Not tested with the active version of WooCommerce WooCommerce Mix and Match: Premium Upcharge: by Kathy Darling – 1.0.0.alpha.1 – Not tested with the active version of WooCommerce WooCommerce Mix and Match: Sold Individually: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce Mix and Match Products: by Kathy Darling – 1.8.0 – Not tested with the active version of WooCommerce WooCommerce Multi-currency: by WooCommerce – 1.14.3-patched – Not tested with the active version of WooCommerce WooCommerce Name Your Price: by Kathy Darling – 2.10.0 – Not tested with the active version of WooCommerce WooCommerce Name Your Price + Subscribe All the Things Bridge: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce Name Your Price: Donation improvements: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce Name Your Price: Loop Inputs: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce Name Your Price: Variable Billing Periods Improvement: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce Name Your Price Event Tickets: by Kathy Darling – 1.1.1 – Not tested with the active version of WooCommerce WooCommerce Name Your Price Sold Individually: by Kathy Darling – 1.2.0 – Not tested with the active version of WooCommerce WooCommerce New User Approved Email: by Kathy Darling – 1.0.0-beta – Not tested with the active version of WooCommerce WooCommerce new variable product: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce NYP Subscription Switching: by Kathy Darling – 0.2.0 – Not tested with the active version of WooCommerce WooCommerce One Page Checkout: by Automattic – 1.7.3 WooCommerce PayPal Checkout Gateway: by WooCommerce – 1.6.18 – 1.6.19 is available – Not tested with the active version of WooCommerce WooCommerce PDF Product Vouchers: by SkyVerge – 3.3.1 – Not tested with the active version of WooCommerce WooCommerce Photography: by WooCommerce – 1.0.12 – Not tested with the active version of WooCommerce WooCommerce Points and Rewards: by WooCommerce – 1.6.11 – Not tested with the active version of WooCommerce WooCommerce Pre-Orders: by WooCommerce – 1.5.9 – Not tested with the active version of WooCommerce WooCommerce Print Invoices/Packing Lists: by SkyVerge – 3.5.0 – Not tested with the active version of WooCommerce WooCommerce Product Add-ons: by WooCommerce – 3.0.20 – Not tested with the active version of WooCommerce WooCommerce Product Bundles: by SomewhereWarm – 5.13.3 – Not tested with the active version of WooCommerce WooCommerce Product Bundles - Bulk Discounts: by SomewhereWarm – 1.0.4 – Not tested with the active version of WooCommerce WooCommerce Product Bundles - Bundle-Sells: by SomewhereWarm – 1.0.5 – Not tested with the active version of WooCommerce WooCommerce Quarterly Shipping Multiplier: by Kathy Darling – 1.0 – Not tested with the active version of WooCommerce WooCommerce Quick View: by WooCommerce – 1.2.6 WooCommerce Remove All Products: by Gabriel Reguly – 1.0.6 – Not tested with the active version of WooCommerce WooCommerce Shipping Per Product v2: by WooCommerce – 2.2.13 – Not tested with the active version of WooCommerce WooCommerce Ship to Multiple Addresses: by WooCommerce – 3.6.1 – Not tested with the active version of WooCommerce WooCommerce Shortcodes: by WooThemes Claudio Sanches – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce Simple Auction: by wpgenie – 1.2.31 – Not tested with the active version of WooCommerce WooCommerce Smart Coupons: by StoreApps – 3.6.0 – Not tested with the active version of WooCommerce WooCommerce Square: by WooCommerce – 2.0.8 – Not tested with the active version of WooCommerce WooCommerce Stripe Gateway: by WooCommerce – 4.3.1 – Not tested with the active version of WooCommerce WooCommerce Subscriptions: by WooCommerce – 3.0.1 WooCommerce Subscriptions Gifting: by Prospress Inc. – 2.0.1 – Not tested with the active version of WooCommerce WooCommerce Table Rate Shipping: by WooCommerce – 3.0.14 – Not tested with the active version of WooCommerce WooCommerce Tiered Price Table: by bycrik – 2.3.3 – Not tested with the active version of WooCommerce WooCommerce UPS Shipping: by WooCommerce – 3.2.9 – Not tested with the active version of WooCommerce WooCommerce Variable Step: by Kathy Darling – 1.0.0 – Not tested with the active version of WooCommerce WooCommerce Waitlist: by WooCommerce – 2.1.9 – Not tested with the active version of WooCommerce WooCommerce Wholesale Order Form: by Rymera Web Co – 1.10 – Not tested with the active version of WooCommerce WooCommerce Wholesale Prices: by Rymera Web Co – 1.10 – Not tested with the active version of WooCommerce WooCommerce WishLists: by Lucas Stark – 2.1.13 – Not tested with the active version of WooCommerce WooCommerce Workshop Attendee Details: by Kathy Darling – 0.2.0 – Not tested with the active version of WooCommerce Woo Limit One Purchase: by Adam Bowen – 2.1.2 Woo Update Variations In Cart: by Ganesh – 0.0.7 – Not tested with the active version of WooCommerce WordPress Beta Tester: by Peter Westwood Andy Fragen – 2.1.0 WordPress Importer: by wordpressdotorg – 0.6.4 WordPress Persistent Login: by Luke Seager – 1.3.8 Wp-action-trace: by Cal Evans – 1.0 WP-PageNavi: by Lester 'GaMerZ' Chan – 2.93.1 WP Migrate DB Pro: by Delicious Brains – 1.9.8 WP Migrate DB Pro Media Files: by Delicious Brains – 1.4.14 WP Migrate DB Pro Theme & Plugin Files: by Delicious Brains – 1.0.5 WPML Media: by OnTheGoSystems – 2.5.5 WPML Multilingual CMS: by OnTheGoSystems – 4.3.5 WPML String Translation: by OnTheGoSystems – 3.0.5 WPML Translation Management: by OnTheGoSystems – 2.9.3 WPSE 332513: by Sally CJ – 20190402.2 WP Security Question: by flippercode – 1.0.4 ### Must Use Plugins (1) ### WC Disable Annoying Things: by Kathy Darling – 1.0 ### Settings ### API Enabled: – Force SSL: – Currency: USD ($) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: auction (auction) bundle (bundle) composite (composite) external (external) grouped (grouped) mix and match (mix-and-match) simple (simple) subscription (subscription) 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 WooCommerce.com: – ### WC Pages ### Shop base: #510 - /shop/ Cart: #511 - /cart/ Checkout: #512 - /checkout/ My account: #513 - /my-account/ Terms and conditions: ❌ Page not set ### Theme ### Name: A Twenty Nineteen Child Theme Version: 1.0 Author URL: http://kathyisawesome.com/ Child Theme: ✔ Parent Theme Name: Twenty Nineteen Parent Theme Version: 1.4 Parent Theme Author URL: https://wordpress.org/ WooCommerce Support: ✔ ### Templates ### Overrides: twentynineteen-child/woocommerce/myaccount\my-orders.php ### Action Scheduler ### Complete: 0 Oldest: – Newest: – Pending: 0 Oldest: – Newest: – Canceled: 0 Oldest: – Newest: – In-progress: 0 Oldest: – Newest: – Failed: 0 Oldest: – Newest: – ` ```

@nerrad commented on Fri Feb 07 2020

This belongs in the blocks repo so I'll move there and it will be addressed there as well.

nerrad commented 4 years ago

Thanks for taking the time to report this issue Kathy!

While it may appear this is a bug, the filter you used is not expected to affect the behaviour of the All Products block. The "Products by Category" block is a server side rendered block and thus it's html layout etc is rendered on the server before being served to the client. The "All Products" block is a new type of block that is completely rendered client side and gets products (and other data) over the wire via the REST API.

I'm going to close this issue but feel free to add additional feedback and/or comments.

I wrote the following post in the WooCommerce community slack and I'm copying here for others that might stumble on this issue:


For those using All Products block, it works a bit differently than server side rendered blocks in a few key areas:

Each element for a product in the grid is actually a “inner block”. So product title, product description, product image etc are all blocks themselves (which allows for merchants to use the block editor to control the layout of the elements for each product in the grid). Down the road we’ll be adding some additional controls etc for these “atomic” blocks that give flexibility and immediate feedback for how things change when the blocks are modified. The products are supplied via REST api to power the block components on the frontend. We do have some basic extensibility for developers in place right now but do plan on adding more as we iterate and get feedback from developers on what they’d like to see. However, for the most part, with this new style of block the extensibility will not be found php side. Currently, you can use the registerInnerBlock api for registering additional blocks to be available for using in the product grid. You can see an example of this in use here.

Admittedly, there is sparse documentation for this currently because we’re wanting the interface to percolate a bit before we document it fully.

golendercaria commented 4 years ago

@nerrad There are two features that are sorely lacking. 1) Allow block pre-filtering all products based on one / attributes / categories. There is example of shunk to your API REST ` add_action('wp_loaded', 'test_rest_api_init', 10, 1); function test_rest_api_init( $rest_server ){

    if( isset($_GET["orderby"]) ){
        if( isset($_GET["attributes"]) ){
            $finded_brand = false;
            foreach($_GET["attributes"] as $key => $attribute){
                if( $attribute["attribute"] == "pa_beer_brand" ){
                    $finded_brand = true;
                }
            }
            if( !$finded_brand ){
                $_GET["attributes"][] = array(
                    "attribute" => "pa_beer_brand",
                    "operator" => "in",
                    "slug" => array(
                        "bofferding"
                    )
                );
            }
        }else{
            $_GET["attributes"] = array();
            $_GET["attributes"][] = array(
                "attribute" => "pa_beer_brand",
                "operator" => "in",
                "slug" => array(
                    "bofferding"
                )
            );
        }
    }
}`

2) As explained above, I find it surprising that there is no way to display special field of product like color attributes (for example) for me the addition of a shortcode would have solved a lot of problems, but still to do with the return of the rest API which returns a very specific data schema => which I fully understand, but filter hooks on diagrams and data returns would have helped (I think easy) to solve the problem.

I am available if you want to discuss these two features.

nerrad commented 4 years ago

Hi Yann,

Is the issue in #1705 the same request as what you've asked for? If so, then ya we've seen your request (it just hasn't been triaged yet because our team has been away on a team meetup). I appreciate you expanding on your request with more details here, but it'd be good if you add your above comment to that issue to keep all the details in one issue so we don't miss things when we evaluate potential new enhancements for the blocks.

helgatheviking commented 4 years ago

Hi @nerrad Thanks for the explanation about the different types of blocks. So you are saying there is NO way to modify the content of the inner block? If not a bug, could that be considered at least a feature request? It's in a grid and it seems logical that the filter I mentioned would work there. From my point of view, that you can modify the template of the shop archive loop everywhere or per-term, but not do the same with blocks seems pretty odd.

nerrad commented 4 years ago

So you are saying there is NO way to modify the content of the inner block?

Currently no. The block does not pull its rendered html content from php, it comes from a new (experimental) store/products api.

It's in a grid and it seems logical that the filter I mentioned would work there. From my point of view, that you can modify the template of the shop archive loop everywhere or per-term, but not do the same with blocks seems pretty odd.

I agree it may seem logical from the perspective of this is how WordPress and WooCommerce html content has been modified for a number of years. However, these particular blocks (All Products, the atomic inner blocks, and the filter blocks) which are not using server side rendering (but are rendered entirely client side) is implementing a new way of rendering content. Over time, the inner-blocks will be enhanced (or can be replaced or new ones added by developers introducing alternatives) so that merchants can (optionally) have direct control over the looks and layout of wherever the block is used. This could include additional controls for affecting style/layout (eg. list vs grid), or new blocks for inserting/displaying additional content (attribute terms etc).

The big idea here is that it allows merchants to more easily adjust their content without having to dive into theme or plugin code and see changes applied immediately. While developers can focus on building the blocks or pieces offering additional options to merchants.

Forward looking, these new atomic blocks will also work well with a potential new templating system in Gutenberg where the blocks might be added to templates.