2010-12-23 36 views
3

當爲條件操作添加自定義php代碼時,drupal/ubercart提供了兩個php變量($ order和$ account),用於保存剛剛完成的checkout的訂單和賬戶信息。自定義php代碼的drupal條件操作

我無法在互聯網上的任何地方找到關於這些對象是如何構建的文檔...任何人都知道這個文檔是在哪裏或如何設置這些對象???

感謝

+0

文檔似乎缺乏......你可以在你的測試環境中使用var_dump結構嗎? – 2010-12-24 15:01:58

回答

2
  • $account是用戶對象。
  • $order是ubercart訂單對象。

這兩個對象都有一些最小定義值,但它們確實可以包含任何東西。原因是,Drupal將允許模塊擴展用戶對象,而ubercart將允許模塊擴展訂單對象。

在這種情況下做最好的事情是檢查對象,找出如何得到你需要的東西。

該devel模塊將允許您使用dsm()漂亮打印變量或使用dd()轉儲變量t日誌文件。這是獲取變量信息的兩種方法。

+0

+1:dsm()或dpm()是做這件事的方法。沒有關於這些變量的文檔的單一來源,因爲它們可能會被任何數量的模塊鉤子修改 – anschauung 2010-12-28 19:41:27

4

這裏的$訂單對象看起來像一個相當標準的安裝(可能會根據您的安裝是一個有點不同當然產品的順序決定哪些項目部分看起來像:

stdClass Object 
(
    [order_id] => 123 
    [uid] => 456 
    [order_status] => payment_received 
    [order_total] => 100 
    [product_count] => 1 
    [primary_email] => [email protected] 
    [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] => 
       ) 

     ) 

)