Skip to content

Instantly share code, notes, and snippets.

View mattsherman's full-sized avatar

Matt Sherman mattsherman

View GitHub Profile
@mattsherman
mattsherman / example-complex-product-meta-fields.php
Created April 29, 2024 20:05
Example how to handle "packed" meta values in WooCommerce's new product editor
<?php
use Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplates\GroupInterface;
add_filter(
'woocommerce_rest_prepare_product_object',
function ( $response, $post ) {
$custom_regular_prices_encoded = get_post_meta( $post->get_id(), '_custom_regular_prices', true );
$custom_regular_prices = json_decode(