پرش به محتویات

"Filter: bricks/query_filters/index_post/wcField"

یک قلاب تخصصی برای نمایه سازی فیلدهای محصول WooCommerce (مانند قیمت، وضعیت سهام، رتبه بندی) هنگام ذخیره یک محصول. این به فهرست Query Filters اجازه می‌دهد تا با داده‌های محصول WooCommerce به روز بماند.

پارامترها

  • $rows (array): Array of index rows to be inserted.
  • $post_id (int): The ID of the product (post) being indexed.
  • $elements (array): Array of filter elements targeting this product.

نمونه استفاده

add_filter( 'bricks/query_filters/index_post/wcField', function( $rows, $post_id, $elements ) {
    // This filter is typically used internally by Bricks to handle WooCommerce fields.
    // However, you could hook into it to index custom WooCommerce product data.

    // Example: Index a custom product property
    $product = wc_get_product( $post_id );
    if ( $product ) {
        // ... generate index rows ...
    }

    return $rows;
}, 10, 3 );