如何使用服务模块获取 Drupal Commerce 中的产品价格?

发布于 2025-01-06 21:34:38 字数 473 浏览 3 评论 0原文

我安装了服务模块和 REST 服务器来获取产品列表和详细信息。我只能获取产品显示节点和产品 id,

但如何从 Drupal Commerce 获取产品价格和可用性信息。

所有节点列表(包括产品展示节点)

http://drupalcommerce.myappdemo.com/services/node

获取单品展示节点 http://drupalcommerce.myappdemo.com/services/node/37

但它确实给出了产品 ID,但不是产品价格。

请告诉我如何获得一个。

I installed Services Module and REST Server to get list of products and details. I can only get product display nodes and product id,

but how to get product price and availability info from Drupal Commerce.

List of all nodes (including product display nodes)

http://drupalcommerce.myappdemo.com/services/node

Get single product display node
http://drupalcommerce.myappdemo.com/services/node/37

But it does give product id, but not product price.

Please give me an idea how to get one.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终弃我 2025-01-13 21:34:38

检查这个 api 它会对你有帮助

 $order = commerce_cart_order_load($uid);
   // Get the order for user just logged in.
    $order_authenticated = reset(commerce_order_load_multiple(array(), array('uid' => $this->store_customer->uid, 'status' => 'cart'), TRUE));
   //update the order status
    $form_state['order'] = commerce_order_status_update($order, 'checkout_checkout', TRUE);
    // Load the order status object for the current order.
    $order_status = commerce_order_status_load($order->status);
    $profile = commerce_customer_profile_load($order->data['profiles'][$checkout_pane['pane_id']]);
    $order = commerce_order_load($order->order_id);
   // Give other modules a chance to alter the order statuses.
    drupal_alter('commerce_order_status_info', $order_statuses);
     $order_state = commerce_order_state_load($order_status['state']);
      // Load the line items for temporary storage in the form array.
    $line_items = commerce_line_item_load_multiple($line_item_ids);
    // load line item
    commerce_line_item_load($line_item_id)
    //load the commerce product
    $product = commerce_product_load($product_id)
     // Load the referenced products.
    $products = commerce_product_load_multiple($product_ids);

check this api's it will help you

 $order = commerce_cart_order_load($uid);
   // Get the order for user just logged in.
    $order_authenticated = reset(commerce_order_load_multiple(array(), array('uid' => $this->store_customer->uid, 'status' => 'cart'), TRUE));
   //update the order status
    $form_state['order'] = commerce_order_status_update($order, 'checkout_checkout', TRUE);
    // Load the order status object for the current order.
    $order_status = commerce_order_status_load($order->status);
    $profile = commerce_customer_profile_load($order->data['profiles'][$checkout_pane['pane_id']]);
    $order = commerce_order_load($order->order_id);
   // Give other modules a chance to alter the order statuses.
    drupal_alter('commerce_order_status_info', $order_statuses);
     $order_state = commerce_order_state_load($order_status['state']);
      // Load the line items for temporary storage in the form array.
    $line_items = commerce_line_item_load_multiple($line_item_ids);
    // load line item
    commerce_line_item_load($line_item_id)
    //load the commerce product
    $product = commerce_product_load($product_id)
     // Load the referenced products.
    $products = commerce_product_load_multiple($product_ids);
我很OK 2025-01-13 21:34:38
  1. 安装商务服务模块。

  2. 启用“产品显示 ->”检索”和“产品 ->检索”服务端点的资源。

  3. ?q=my_service_endpoint/product-display/123.json 上执行 GET,这将获取节点 123 的产品显示信息。这还将包含产品的 id该节点引用的信息(例如产品 456)以及产品的价格。

  4. 可选,对 ?q=my_service_endpoint/product/456.json 执行 GET,这将获取 ID 为 456 的产品的更完整的产品信息。

  1. Install the Commerce Services module.

  2. Enable the 'product-display -> retrieve' and 'product -> retrieve' resources for your Services endpoint.

  3. Do a GET on ?q=my_service_endpoint/product-display/123.json , this will get the product display information for node 123. This will also contain the ids of the product(s) that are referenced by this node (e.g. product 456), along with the product's price.

  4. Optional, do a GET on ?q=my_service_endpoint/product/456.json , this will get more complete product information for the product with id 456.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文