在为条件操作添加自定义 php 代码时,drupal/ubercart 提供了两个 php 变量($order 和 $account),它们保存有关刚刚完成的结帐的订单和帐户的信息。
我在 Internet 文档上找不到任何关于这些对象的结构的文档...任何人都知道此文档在哪里或这些对象是如何设置的???
谢谢
在为条件操作添加自定义 php 代码时,drupal/ubercart 提供了两个 php 变量($order 和 $account),它们保存有关刚刚完成的结帐的订单和帐户的信息。
我在 Internet 文档上找不到任何关于这些对象的结构的文档...任何人都知道此文档在哪里或这些对象是如何设置的???
谢谢
这是 $order 对象在相当标准的安装中的样子(根据您的安装可能会有所不同。当然,订单中的产品决定了 items 部分的外观:
stdClass Object
(
[order_id] => 123
[uid] => 456
[order_status] => payment_received
[order_total] => 100
[product_count] => 1
[primary_email] => test@example.com
[delivery_first_name] => Test
[delivery_last_name] => Customer
[delivery_phone] => 123-123-1234
[delivery_company] => ABC Company, Inc.
[delivery_street1] => 123 Easy St.
[delivery_street2] =>
[delivery_city] => Anytown
[delivery_zone] => 39
[delivery_postal_code] => 12345
[delivery_country] => 840
[billing_first_name] => Test
[billing_last_name] => Customer
[billing_phone] => 123-123-1234
[billing_company] => ABC Company, Inc.
[billing_street1] => 123 Easy St.
[billing_street2] =>
[billing_city] => Anytown
[billing_zone] => 39
[billing_postal_code] => 12345
[billing_country] => 840
[payment_method] => credit
[data] => Array
(
[cc_data] => ***encrypted credit card data***
)
[created] => 1295455508
[modified] => 1295457962
[host] => 127.0.0.1
[products] => Array
(
[0] => stdClass Object
(
[order_product_id] => 245
[order_id] => 123
[nid] => 5
[title] => Test Product
[manufacturer] =>
[model] => TEST-PRODUCT-SKU
[qty] => 1
[cost] => 100.00000
[price] => 100.00000
[weight] => 0
[data] => Array
(
[attributes] => Array
(
)
[shippable] => 1
[module] => uc_product
)
[order_uid] => 456
)
)
[payment_details] =>
[quote] => Array
(
[method] => flatrate_1
[accessorials] => 0
[rate] => 7.00000
[quote_form] =>
)
[line_items] => Array
(
[0] => Array
(
[line_item_id] => subtotal
[type] => subtotal
[title] => Subtotal
[amount] => 100
[weight] => 0
[data] =>
)
[1] => Array
(
[line_item_id] => 194
[type] => shipping
[title] => Flat Rate Shipping
[amount] => 7.00000
[weight] => 1
[data] =>
)
)
)
$account
是用户对象。$order
是 ubercart 订单对象。这两个对象都有一些最低定义的值,但它们实际上可以包含任何东西。原因是 Drupal 将允许模块扩展用户对象,而 ubercart 将允许模块扩展订单对象。
在这种情况下,最好的办法是检查对象以确定如何获得所需的东西。
开发模块将允许您使用漂亮dsm()
的打印变量或使用dd()
. 这是获取变量信息的两种方法。