• 16-12-2017, 10:46:57
    #1
    Merhabalar,

    'details_attributes' => array (
            array (
                'product_id'     => '5542004', // the products
                'quantity'       => '3',
                'unit_price'     => '15.24',
                'vat_rate'       => '18',
                'discount_type'  => 'amount',
                'discount_value' => '0',
            ),
    		array (
                'product_id'     => '5542003', // the products
                'quantity'       => '1',
                'unit_price'     => '22.99',
                'vat_rate'       => '18',
                'discount_type'  => 'amount',
                'discount_value' => '0',
            ),
    Benim yukarıdakine uygun olarak sıralı ürünleri çekmem ve buraya yerleştirmem lazım.

    Verileri sıralı olarak;
    $sku[] = $product->get_sku();
    $qty[] = $item->get_quantity();
    $total[] = $order->get_item_meta($item_key, '_line_total', true);
    burdan çekiyorum. Ama bir türlü yazdıramadım PHP bilgim fazla yok, for, foreach ile vs denedim beceremedim. Yardımcı olabilir misiniz?
    Şimdiden teşekkürler.
  • 16-12-2017, 10:54:09
    #2
    Bu şekilde yazdırabilirsiniz.
    foreach($deger["details_attributes"] as $value)
      {
       $sku[] = $value['product_id'];
       $qty[] = $value["quantity"];
       $total[] = $value['unit_price'];
      }
  • 16-12-2017, 10:58:02
    #3
    Üyeliği durduruldu
    http://webirinci.com/yazilim/php-dizi-tanimlama/ bu sayfaya bakarak diziler hakkında bilgi alabilirsin
  • 16-12-2017, 16:44:01
    #4
    Teşekkürler cevabınız için. Daha da açayım sorumu, anlaşılır olması açısından.

    Kodumuz bu.
    	  // create a new purchase bill
    $purchase = $muhasebe->make('sale')->create([
        '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' => [
    	 	[
                'product_id'     => '5542003', // the products
                'quantity'       => '3',
                'unit_price'     => '11.29',
                'vat_rate'       => '18',
                'discount_type'  => 'amount',
                'discount_value' => '0',
            ],
    		[
                'product_id'     => '5542004', // the products
                'quantity'       => '2',
                'unit_price'     => '15.29',
                'vat_rate'       => '18',
                'discount_type'  => 'amount',
                'discount_value' => '0',
            ],
    	],
    ]);
    Yukarıdaki kodda yer alan details_attributes içinde kaç adet ürün varsa onların detayları sıra ile yer alması gerekiyor.

    foreach ($order->get_items() as $item_key => $item) {
        $item_data = $item->get_data();
    	$product = $order->get_product_from_item($item);
    	$sku[] = $parasut->make('product')->getProduct($product->get_sku());
    	$qty[] = $item->get_quantity();
    	$total[] = $order->get_item_meta($item_key, '_line_total', true);
    }
    Bu kod ile siparişte yer alan ürünleri çekiyorum ama ilk kodun içine yazdıramıyorum. İlk mesajımda da belirttiğim gibi php bilgim çok olmadığı için yanlış belirtmiş de olabilirim. Okumadığım Türkçe/İngilizce makale kalmadı ama bir türlü beceremedim.

    Teşekkürler şimdiden.