いくつかのカスタム テーブルがあり、小枝で高度なカスタム フィールド (acf) を使用しています。これらのフィールドはカスタム テーブルに保存されます。
例えば:
custom_table1
、custom_table2
、custom_table1_table2_relation
その他。
これらは管理製品パネルで編集でき、製品データに関連するオブジェクトとして表示されます。次に、それらを連想配列にマージします。
私はこれを持っています:
/*output*/
[post] => TimberPost Object (
[ImageClass] => TimberImage
[PostClass] => TimberPost
[object_type] => post
[class] => post-8 product type-product
[id] => 1
[post_author] => 1
[post_content] => description
[custom] => Array (
[table1-field1] => data
[table1-field2] => data
[table2_field1] => data
[table2_field] => data
)
)
そして私はこれが好きです:
$products['products'] = array(
'id' => 1,
'post_content' => 'description',
'post_title' => 'title',
'and_so_on' => 'stuff',
[ 'custom' ] => array(
'table1' => array(
'data1' => 'content',
'data2' => 'content',
),
'table2' => array(
'data1' => 'content',
'data2' => 'content',
) /*and so on*/
)
);
WC_Class を拡張して、これらをフロントで呼び出すアクションを作成しようとしました
これは単なるスニペットの例です
class WCIntegrationProductIntegration extends WC_Query {
function __construct() {
add_action( 'woocommerce_custom_product_data', array( $this->_get_custom_product_data ) );
}
public function _get_custom_product_data() {
global $woocommerce;
$custom = array_merge(
array(
/*get custom tables and data*/
'table' = $table1,
'data' array($fields),
)
);
$product = array_merge(
array(
/*get productss and data*/
'table' = $table1,
'data' array($fields),
)
);
$the_query = new WP_Query();
}
}
new WCIntegrationProductIntegration();
しかし、私はそれを取得しません。私は少し混乱しています