2015-09-04 101 views
1

我已經創建了自定義模塊來發送捲曲請求。在這裏我得到當前用戶的送貨地址,但我想要獲取產品詳細信息以及訂單確認頁面。我怎樣才能做到這一點?如何在prestashop的訂單確認頁面上獲取產品詳細信息?

這裏是我的代碼:

public function hookOrderConfirmation($params) 
    { 
    **Here i want to print product details** 
    echo $this->context->customer->firstname ."<br/>"; 
    echo $this->context->customer->lastname ."<br/>"; 
    echo $this->context->customer->email ."<br/>"; 
    die("GET ALL DETAILS."); 

    //set POST variables 
    $url = 'http://localhost/wrd-folder/web-service/'; 
    $fields = array(
       'first_name' => urlencode("Testing1"), 
       'last_name' => urlencode("Testing2"), 
       'username' => urlencode("Testing1"), 
       'email' => urlencode("[email protected]"), 
       'membership_id' => urlencode("676"), 
       'password' => urlencode("12345678"), 
       'password2' => urlencode("12345678") 
      ); 

    //url-ify the data for the POST 
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } 
    rtrim($fields_string, '&'); 

    //open connection 
    $ch = curl_init(); 

    //set the url, number of POST vars, POST data 
    curl_setopt($ch,CURLOPT_URL, $url); 
    curl_setopt($ch,CURLOPT_POST, count($fields)); 
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); 

    //execute post 
    $result = curl_exec($ch); 

    //close connection 
    curl_close($ch); 

    //Lets display our template file. 
    return $this->display(__FILE__, 'sentcurl.tpl'); 

    } // End of hookOrderConfirmation 

回答

1

在幾行就可以acomplish此任務。你有兩個選擇:

  1. 獲得的產品陣列,並且他們的價格

    $order = $params['objOrder']; 
    // array with products with price, quantity (with taxes and without) 
    $products = $order->getProducts(); 
    
  2. 獲得的產品更詳細的數組:

    $order = $params['objOrder']; 
    $products_with_details = $order->getProductsDetail(); 
    
+0

感謝Rufein您的回覆。 .. – user1990

相關問題