2017-12-17 3 views
-4

api로 작업하고 싶습니다. 그것이 작동하지PHP 배열이 작동하지 않습니다. 뭐가 문제 야?

public function getProductFromOrder() 
{ 
    $sku = array(5542003,5542004); 
    $qty = array("3","1"); 
    $total = array("11.29","12.00"); 

    for($i=0; $i<count($sku); $i++){ 
     $urunler[$i] = array(
        'product_id'  => $sku[$i], // the products 
        'quantity'  => '3', 
        'unit_price'  => '12.99', 
        'vat_rate'  => '18', 
        'discount_type' => 'amount', 
        'discount_value' => '0', 
      ); 
     print ($urunler[$i]); 
    } 
} 

: 여기

// create a new purchase bill 
$purchase = $parasut->make('sale')->create(array (
    'description' => $siparis, 
    'invoice_id'  => null, 
    'invoice_series' => null, 
    'currency'  => 'TRL', 
    'item_type'  => 'invoice', 
    'issue_date'  => $order_date_created, 
    'due_date'  => $order_date_created, 
    'contact_id'  => $contactToken, 
    'category_id' => null, 
    'archived'  => false, 
    'billing_address' => $user_address, 
    'billing_fax' => null, 
    'billing_phone' => $user_phone, 
    'details_attributes' => array (
     $parasut->make('product')->getProductFromOrder(), // the products 
    ), 
)); 

이 getProductFromOrder() 함수입니다 :

여기 내 코드입니다. 첫 번째 코드를 실행하면 제품이 표시되지 않습니다. 실수는 어디 있습니까?

미리 도움을 청하십시오. 이 대신에

+3

'print_r ($ products [$ i]);'시도해보십시오. – mega6382

+1

[PHP에서 배열을 에코하는 방법] 복제본 (https://stackoverflow.com/questions/9816889/how-to-echo-an) -array-in-php) –

답변

1

변경 기능 getProductFromOrder() : 대신 print

public function getProductFromOrder() 
{ 
    $sku = array(5542003,5542004); 
    $qty = array("3","1"); 
    $total = array("11.29","12.00"); 

    for($i=0; $i<count($sku); $i++){ 
     $urunler[$i] = array(
        'product_id'  => $sku[$i], // the products 
        'quantity'  => '3', 
        'unit_price'  => '12.99', 
        'vat_rate'  => '18', 
        'discount_type' => 'amount', 
        'discount_value' => '0', 
      ); 
    } 
    return $urunler; 
} 

사용 return와는 for 루프 외부 return 물품.

관련 문제