Guest User

Untitled

a guest
Oct 20th, 2016
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $data = [
  3.     'name' => 'Premium Quality',
  4.     'type' => 'simple',
  5.     'regular_price' => '21.99',
  6.     'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.',
  7.     'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
  8.     'categories' => [
  9.         [
  10.             'id' => 9
  11.         ],
  12.         [
  13.             'id' => 14
  14.         ]
  15.     ],
  16.     'images' => [
  17.         [
  18.             'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
  19.             'position' => 0
  20.         ],
  21.         [
  22.             'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
  23.             'position' => 1
  24.         ]
  25.     ],
  26.     'downloadable' => true,
  27.     'downloads' => [
  28.         [  
  29.  
  30.             id => md5('path to file'), //http://php.net/manual/en/function.md5-file.php
  31.             name => 'filename.pdf',
  32.             file => '/uploads/pdfs/file.pdf'
  33.         ]
  34.     ]
  35. ];
  36.  
  37. print_r($woocommerce->post('products', $data));
  38. ?>
RAW Paste Data