Кемеровские программисты php общаются здесь
Anonymous
Получите защищенный массив метаданных элемента пользовательского заказа из заказа WooCommerce.
Сообщение
Anonymous » 07 окт 2024, 08:44
Я пытаюсь использовать фильтр woocommerce_get_order_item_totals, чтобы добавить дополнительную информацию в итоговые суммы заказов (о заказах и уведомлениях по электронной почте).
Код: Выделить всё
add_filter( 'woocommerce_get_order_item_totals', 'display_email_topay', 10, 2 );
function display_email_topay( $total_rows, $order ) {
$total_rows['recurr_not'] = array(
'label' => __( '2nd Installment:', 'woocommerce' ),
'value' => 'DATA NEEDS TO GO HERE' //
[status_transition:protected] =>
[data:protected] => Array
(
[parent_id] => 0
[status] => on-hold
[currency] => GBP
[version] => 4.5.2
[prices_include_tax] =>
[date_created] => WC_DateTime Object
(
[utc_offset:protected] => 0
[date] => 2020-10-04 18:25:38.000000
[timezone_type] => 3
[timezone] => Europe/London
)
[date_modified] => WC_DateTime Object
(
[utc_offset:protected] => 0
[date] => 2020-10-04 18:25:38.000000
[timezone_type] => 3
[timezone] => Europe/London
)
[discount_total] => 0
[discount_tax] => 0
[shipping_total] => 0.00
[shipping_tax] => 0
[cart_tax] => 0
[total] => 2.00
[total_tax] => 0
[customer_id] => 1
[order_key] => wc_order_FeOmJ7jXgWF4R
[billing] => Array
(
[first_name] => Jon
[last_name] => Conway
[company] =>
[address_1] =>
[address_2] =>
[city] => Frome
[state] =>
[postcode] =>
[country] =>
[email] =>
[phone] =>
)
[shipping] => Array
(
[first_name] =>
[last_name] =>
[company] =>
[address_1] =>
[address_2] =>
[city] =>
[state] =>
[postcode] =>
[country] =>
)
[payment_method] => bacs
[payment_method_title] => Direct bank transfer
[transaction_id] =>
[customer_ip_address] => 127.0.0.1
[customer_user_agent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15
[created_via] => checkout
[customer_note] =>
[date_completed] =>
[date_paid] =>
[cart_hash] => cb56eda51b920dc5fbffac1c03fe33b1
)
[items:protected] => Array
(
[line_items] => Array
(
[78] => WC_Order_Item_Product Object
(
[extra_data:protected] => Array
(
[product_id] => 0
[variation_id] => 0
[quantity] => 1
[tax_class] =>
[subtotal] => 0
[subtotal_tax] => 0
[total] => 0
[total_tax] => 0
[taxes] => Array
(
[subtotal] => Array
(
)
[total] => Array
(
)
)
)
[data:protected] => Array
(
[order_id] => 1433
[name] => Online concert
[product_id] => 746
[variation_id] => 0
[quantity] => 1
[tax_class] =>
[subtotal] => 2
[subtotal_tax] => 0
[total] => 2
[total_tax] => 0
[taxes] => Array
(
[total] => Array
(
)
[subtotal] => Array
(
)
)
)
[cache_group:protected] => order-items
[meta_type:protected] => order_item
[object_type:protected] => order_item
[id:protected] => 78
[changes:protected] => Array
(
)
[object_read:protected] => 1
[default_data:protected] => Array
(
[order_id] => 0
[name] =>
[product_id] => 0
[variation_id] => 0
[quantity] => 1
[tax_class] =>
[subtotal] => 0
[subtotal_tax] => 0
[total] => 0
[total_tax] => 0
[taxes] => Array
(
[subtotal] => Array
(
)
[total] => Array
(
)
)
)
[data_store:protected] => WC_Data_Store Object
(
[instance:WC_Data_Store:private] => WC_Order_Item_Product_Data_Store Object
(
[internal_meta_keys:protected] => Array
(
[0] => _order_id
[1] => _name
[2] => _product_id
[3] => _variation_id
[4] => _quantity
[5] => _tax_class
[6] => _subtotal
[7] => _subtotal_tax
[8] => _total
[9] => _total_tax
[10] => _taxes
[11] => _product_id
[12] => _variation_id
[13] => _qty
[14] => _tax_class
[15] => _line_subtotal
[16] => _line_subtotal_tax
[17] => _line_total
[18] => _line_tax
[19] => _line_tax_data
)
[meta_type:protected] => order_item
[object_id_field_for_meta:protected] => order_item_id
[must_exist_meta_keys:protected] => Array
(
)
)
[stores:WC_Data_Store:private] => Array
(
[coupon] => WC_Coupon_Data_Store_CPT
[customer] => WC_Customer_Data_Store
[customer-download] => WC_Customer_Download_Data_Store
[customer-download-log] => WC_Customer_Download_Log_Data_Store
[customer-session] => WC_Customer_Data_Store_Session
[order] => WC_Order_Data_Store_CPT
[order-refund] => WC_Order_Refund_Data_Store_CPT
[order-item] => WC_Order_Item_Data_Store
[order-item-coupon] => WC_Order_Item_Coupon_Data_Store
[order-item-fee] => WC_Order_Item_Fee_Data_Store
[order-item-product] => WC_Order_Item_Product_Data_Store
[order-item-shipping] => WC_Order_Item_Shipping_Data_Store
[order-item-tax] => WC_Order_Item_Tax_Data_Store
[payment-token] => WC_Payment_Token_Data_Store
[product] => MAGE_Product_Data_Store_CPT
[product-grouped] => WC_Product_Grouped_Data_Store_CPT
[product-variable] => WC_Product_Variable_Data_Store_CPT
[product-variation] => WC_Product_Variation_Data_Store_CPT
[shipping-zone] => WC_Shipping_Zone_Data_Store
[webhook] => WC_Webhook_Data_Store
[report-revenue-stats] => Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore
[report-orders] => Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore
[report-orders-stats] => Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore
[report-products] => Automattic\WooCommerce\Admin\API\Reports\Products\DataStore
[report-variations] => Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore
[report-products-stats] => Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore
[report-categories] => Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore
[report-taxes] => Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore
[report-taxes-stats] => Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore
[report-coupons] => Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore
[report-coupons-stats] => Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore
[report-downloads] => Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore
[report-downloads-stats] => Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore
[admin-note] => Automattic\WooCommerce\Admin\Notes\DataStore
[report-customers] => Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore
[report-customers-stats] => Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore
[report-stock-stats] => Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore
)
[current_class_name:WC_Data_Store:private] => WC_Order_Item_Product_Data_Store
[object_type:WC_Data_Store:private] => order-item-product
)
[meta_data:protected] => Array
(
[0] => WC_Meta_Data Object
(
[current_data:protected] => Array
(
[id] => 1496
[key] => Date
[value] => 2020-10-02 10:00:00
)
[data:protected] => Array
(
[id] => 1496
[key] => Date
[value] => 2020-10-02 10:00:00
)
)
[1] => WC_Meta_Data Object
(
[current_data:protected] => Array
(
[id] => 1497
[key] => Adult - £10.00 x 1 =
[value] => £10.00
)
[data:protected] => Array
(
[id] => 1497
[key] => Adult - £10.00 x 1 =
[value] => £10.00
)
)
[2] => WC_Meta_Data Object
(
[current_data:protected] => Array
(
[id] => 1498
[key] => Location
[value] => ,
)
[data:protected] => Array
(
[id] => 1498
[key] => Location
[value] => ,
)
)
[3] => WC_Meta_Data Object
(
[current_data:protected] => Array
(
[id] => 1499
[key] => _event_ticket_info
[value] => Array
(
[0] => Array
(
[ticket_name] => Adult
[ticket_price] => 10
[ticket_qty] => 1
[max_qty] =>
[event_date] => 2020-10-02 10:00:00
)
)
)
[data:protected] => Array
(
[id] => 1499
[key] => _event_ticket_info
[value] => Array
(
[0] => Array
(
[ticket_name] => Adult
[ticket_price] => 10
[ticket_qty] => 1
[max_qty] =>
[event_date] => 2020-10-02 10:00:00
)
)
)
)
[4] => WC_Meta_Data Object
(
[current_data:protected] => Array
(
[id] => 1500
[key] => _event_user_info
[value] => Array
(
)
)
[data:protected] => Array
(
[id] => 1500
[key] => _event_user_info
[value] => Array
(
)
)
)
[5] => WC_Meta_Data Object
(
[current_data:protected] => Array
(
[id] => 1501
[key] => event_id
[value] => 745
)
[data:protected] => Array
(
[id] => 1501
[key] => event_id
[value] => 745
)
)
[6] => WC_Meta_Data Object
(
[current_data:protected] => Array
(
[id] => 1503
[key] => _event_extra_service
[value] => Array
(
)
)
[data:protected] => Array
(
[id] => 1503
[key] => _event_extra_service
[value] => Array
(
)
)
)
)
)
)
... truncated
Я хочу получить доступ:
Код: Выделить всё
[id] => 1499
[key] => _event_ticket_info
[value] => Array
(
[0] => Array
(
[ticket_name] => Adult
[ticket_price] => 10
[ticket_qty] => 1
[max_qty] =>
[event_date] => 2020-10-02 10:00:00
)
)
Чтобы посчитать и получить стоимость от Ticket_price по Ticket_qty.
Возможно ли это? Есть идеи, как получить метаданные этой конкретной позиции заказа?
Подробнее здесь:
https://stackoverflow.com/questions/641 ... erce-order
1728279854
Anonymous
Я пытаюсь использовать фильтр woocommerce_get_order_item_totals, чтобы добавить дополнительную информацию в итоговые суммы заказов (о заказах и уведомлениях по электронной почте). [code]add_filter( 'woocommerce_get_order_item_totals', 'display_email_topay', 10, 2 ); function display_email_topay( $total_rows, $order ) { $total_rows['recurr_not'] = array( 'label' => __( '2nd Installment:', 'woocommerce' ), 'value' => 'DATA NEEDS TO GO HERE' // [status_transition:protected] => [data:protected] => Array ( [parent_id] => 0 [status] => on-hold [currency] => GBP [version] => 4.5.2 [prices_include_tax] => [date_created] => WC_DateTime Object ( [utc_offset:protected] => 0 [date] => 2020-10-04 18:25:38.000000 [timezone_type] => 3 [timezone] => Europe/London ) [date_modified] => WC_DateTime Object ( [utc_offset:protected] => 0 [date] => 2020-10-04 18:25:38.000000 [timezone_type] => 3 [timezone] => Europe/London ) [discount_total] => 0 [discount_tax] => 0 [shipping_total] => 0.00 [shipping_tax] => 0 [cart_tax] => 0 [total] => 2.00 [total_tax] => 0 [customer_id] => 1 [order_key] => wc_order_FeOmJ7jXgWF4R [billing] => Array ( [first_name] => Jon [last_name] => Conway [company] => [address_1] => [address_2] => [city] => Frome [state] => [postcode] => [country] => [email] => [phone] => ) [shipping] => Array ( [first_name] => [last_name] => [company] => [address_1] => [address_2] => [city] => [state] => [postcode] => [country] => ) [payment_method] => bacs [payment_method_title] => Direct bank transfer [transaction_id] => [customer_ip_address] => 127.0.0.1 [customer_user_agent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15 [created_via] => checkout [customer_note] => [date_completed] => [date_paid] => [cart_hash] => cb56eda51b920dc5fbffac1c03fe33b1 ) [items:protected] => Array ( [line_items] => Array ( [78] => WC_Order_Item_Product Object ( [extra_data:protected] => Array ( [product_id] => 0 [variation_id] => 0 [quantity] => 1 [tax_class] => [subtotal] => 0 [subtotal_tax] => 0 [total] => 0 [total_tax] => 0 [taxes] => Array ( [subtotal] => Array ( ) [total] => Array ( ) ) ) [data:protected] => Array ( [order_id] => 1433 [name] => Online concert [product_id] => 746 [variation_id] => 0 [quantity] => 1 [tax_class] => [subtotal] => 2 [subtotal_tax] => 0 [total] => 2 [total_tax] => 0 [taxes] => Array ( [total] => Array ( ) [subtotal] => Array ( ) ) ) [cache_group:protected] => order-items [meta_type:protected] => order_item [object_type:protected] => order_item [id:protected] => 78 [changes:protected] => Array ( ) [object_read:protected] => 1 [default_data:protected] => Array ( [order_id] => 0 [name] => [product_id] => 0 [variation_id] => 0 [quantity] => 1 [tax_class] => [subtotal] => 0 [subtotal_tax] => 0 [total] => 0 [total_tax] => 0 [taxes] => Array ( [subtotal] => Array ( ) [total] => Array ( ) ) ) [data_store:protected] => WC_Data_Store Object ( [instance:WC_Data_Store:private] => WC_Order_Item_Product_Data_Store Object ( [internal_meta_keys:protected] => Array ( [0] => _order_id [1] => _name [2] => _product_id [3] => _variation_id [4] => _quantity [5] => _tax_class [6] => _subtotal [7] => _subtotal_tax [8] => _total [9] => _total_tax [10] => _taxes [11] => _product_id [12] => _variation_id [13] => _qty [14] => _tax_class [15] => _line_subtotal [16] => _line_subtotal_tax [17] => _line_total [18] => _line_tax [19] => _line_tax_data ) [meta_type:protected] => order_item [object_id_field_for_meta:protected] => order_item_id [must_exist_meta_keys:protected] => Array ( ) ) [stores:WC_Data_Store:private] => Array ( [coupon] => WC_Coupon_Data_Store_CPT [customer] => WC_Customer_Data_Store [customer-download] => WC_Customer_Download_Data_Store [customer-download-log] => WC_Customer_Download_Log_Data_Store [customer-session] => WC_Customer_Data_Store_Session [order] => WC_Order_Data_Store_CPT [order-refund] => WC_Order_Refund_Data_Store_CPT [order-item] => WC_Order_Item_Data_Store [order-item-coupon] => WC_Order_Item_Coupon_Data_Store [order-item-fee] => WC_Order_Item_Fee_Data_Store [order-item-product] => WC_Order_Item_Product_Data_Store [order-item-shipping] => WC_Order_Item_Shipping_Data_Store [order-item-tax] => WC_Order_Item_Tax_Data_Store [payment-token] => WC_Payment_Token_Data_Store [product] => MAGE_Product_Data_Store_CPT [product-grouped] => WC_Product_Grouped_Data_Store_CPT [product-variable] => WC_Product_Variable_Data_Store_CPT [product-variation] => WC_Product_Variation_Data_Store_CPT [shipping-zone] => WC_Shipping_Zone_Data_Store [webhook] => WC_Webhook_Data_Store [report-revenue-stats] => Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore [report-orders] => Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore [report-orders-stats] => Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore [report-products] => Automattic\WooCommerce\Admin\API\Reports\Products\DataStore [report-variations] => Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore [report-products-stats] => Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore [report-categories] => Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore [report-taxes] => Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore [report-taxes-stats] => Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore [report-coupons] => Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore [report-coupons-stats] => Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore [report-downloads] => Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore [report-downloads-stats] => Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore [admin-note] => Automattic\WooCommerce\Admin\Notes\DataStore [report-customers] => Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore [report-customers-stats] => Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore [report-stock-stats] => Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore ) [current_class_name:WC_Data_Store:private] => WC_Order_Item_Product_Data_Store [object_type:WC_Data_Store:private] => order-item-product ) [meta_data:protected] => Array ( [0] => WC_Meta_Data Object ( [current_data:protected] => Array ( [id] => 1496 [key] => Date [value] => 2020-10-02 10:00:00 ) [data:protected] => Array ( [id] => 1496 [key] => Date [value] => 2020-10-02 10:00:00 ) ) [1] => WC_Meta_Data Object ( [current_data:protected] => Array ( [id] => 1497 [key] => Adult - £10.00 x 1 = [value] => £10.00 ) [data:protected] => Array ( [id] => 1497 [key] => Adult - £10.00 x 1 = [value] => £10.00 ) ) [2] => WC_Meta_Data Object ( [current_data:protected] => Array ( [id] => 1498 [key] => Location [value] => , ) [data:protected] => Array ( [id] => 1498 [key] => Location [value] => , ) ) [3] => WC_Meta_Data Object ( [current_data:protected] => Array ( [id] => 1499 [key] => _event_ticket_info [value] => Array ( [0] => Array ( [ticket_name] => Adult [ticket_price] => 10 [ticket_qty] => 1 [max_qty] => [event_date] => 2020-10-02 10:00:00 ) ) ) [data:protected] => Array ( [id] => 1499 [key] => _event_ticket_info [value] => Array ( [0] => Array ( [ticket_name] => Adult [ticket_price] => 10 [ticket_qty] => 1 [max_qty] => [event_date] => 2020-10-02 10:00:00 ) ) ) ) [4] => WC_Meta_Data Object ( [current_data:protected] => Array ( [id] => 1500 [key] => _event_user_info [value] => Array ( ) ) [data:protected] => Array ( [id] => 1500 [key] => _event_user_info [value] => Array ( ) ) ) [5] => WC_Meta_Data Object ( [current_data:protected] => Array ( [id] => 1501 [key] => event_id [value] => 745 ) [data:protected] => Array ( [id] => 1501 [key] => event_id [value] => 745 ) ) [6] => WC_Meta_Data Object ( [current_data:protected] => Array ( [id] => 1503 [key] => _event_extra_service [value] => Array ( ) ) [data:protected] => Array ( [id] => 1503 [key] => _event_extra_service [value] => Array ( ) ) ) ) ) ) ... truncated [/code] Я хочу получить доступ: [code][id] => 1499 [key] => _event_ticket_info [value] => Array ( [0] => Array ( [ticket_name] => Adult [ticket_price] => 10 [ticket_qty] => 1 [max_qty] => [event_date] => 2020-10-02 10:00:00 ) ) [/code] Чтобы посчитать и получить стоимость от Ticket_price по Ticket_qty. Возможно ли это? Есть идеи, как получить метаданные этой конкретной позиции заказа? Подробнее здесь: [url]https://stackoverflow.com/questions/64199051/get-protected-custom-order-item-meta-data-array-from-woocommerce-order[/url]
0 Ответы
82 Просмотры
Последнее сообщение Anonymous
16 мар 2024, 21:12
0 Ответы
28 Просмотры
Последнее сообщение Anonymous
15 дек 2024, 20:48
0 Ответы
78 Просмотры
Последнее сообщение Anonymous
01 мар 2024, 20:03
0 Ответы
48 Просмотры
Последнее сообщение Anonymous
06 июл 2024, 22:21
0 Ответы
72 Просмотры
Последнее сообщение Гость
19 сен 2023, 17:42