【问题标题】:How can I get all included products on WordPress Woo-Commerce Plugin如何在 WordPress Woo-Commerce 插件上获取所有包含的产品
【发布时间】:2020-08-18 09:41:20
【问题描述】:

我正在开发 WordPress Woo-Commerce 插件定制。

我在管理页面上添加了产品作为包含产品,例如 Bellow Image。

我想从父产品 ID 中获取所有包含的产品 ID。如果有人对此有解决方案,请告诉我。

问候

【问题讨论】:

    标签: javascript php wordpress woocommerce plugins


    【解决方案1】:

    很高兴认识你。

    要解决您的问题,请将以下代码添加到 plugins/woocommerce-ultimate-giftcard-function。

    foreach ($include_product_new_array as $product_id){
                    $product = wc_get_product( $product_id );
                    $order->add_product($product, 1);
                    //woocommerce_add_order_item($order_id, $product);
                }
                //$order->calculate_totals();
                $order->save(); // Save and sync the data
    

    【讨论】:

    • 但是我在哪里可以获得 $include_product_new_array ?
    • 哦,用这个。 $include_product_ids = array_filter(array_map('absint',explode(',',get_post_meta($product_id,'mwb_wgm_include_per_pro_format',true))));
    猜你喜欢
    • 2014-11-16
    • 2014-10-17
    • 2018-04-05
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    • 1970-01-01
    • 2020-04-03
    相关资源
    最近更新 更多