2015-09-04 172 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

相关问题