小编Noe*_*res的帖子

获取Woocommerce购物车中每个产品的作者ID

在woocommerce中,我需要获得购物车中每个产品的用户ID,该用户ID不是来自客户,而是创建和发布当前购物车中产品的用户(作者发帖)。

我有以下代码:WooCommerce在插件中付款之前获取订单产品详细信息

共享的代码:@LoicTheAztec

foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ){
    $product_id = $cart_item['product_id']; // Product ID
    $product_obj = wc_get_product($product_id); // Product Object
    $product_qty = $cart_item['quantity']; // Product quantity
    $product_price = $cart_item['data']->price; // Product price
    $product_total_stock = $cart_item['data']->total_stock; // Product stock
    $product_type = $cart_item['data']->product_type; // Product type
    $product_name = $cart_item['data']->post->post_title; // Product Title (Name)
    $product_slug = $cart_item['data']->post->post_name; // Product Slug
    $product_description = $cart_item['data']->post->post_content; // Product description
    $product_excerpt = $cart_item['data']->post->post_excerpt; // Product short description
    $product_post_type = $cart_item['data']->post->post_type; // Product post type …
Run Code Online (Sandbox Code Playgroud)

php wordpress cart woocommerce hook-woocommerce

5
推荐指数
1
解决办法
1730
查看次数

标签 统计

cart ×1

hook-woocommerce ×1

php ×1

woocommerce ×1

wordpress ×1