Last active
June 24, 2020 08:08
-
-
Save carrowheap/3873a2e24f882addb080668fad1da859 to your computer and use it in GitHub Desktop.
Revisions
-
carrowheap revised this gist
Jun 24, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public function index() $resp = $client->post('products', $product); // post product variations $data = $client->post('products/' . $resp->id . '/variations', $data); return $this->render('default/index.html.twig', [ -
carrowheap renamed this gist
Jun 24, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
carrowheap created this gist
Jun 24, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ <?php namespace App\Controller; use Automattic\WooCommerce\Client; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; class DefaultController extends AbstractController { public function index() { $client = new Client( 'http://172.22.0.1:8090', 'ck_4e2802c67793d32dba3237f994dbbca45577e2d5', 'cs_796a3ab9ec3fb6bf6482280f3fcfbaa90a71a55c', [ 'wp_api' => true, 'version' => 'wc/v3', 'query_string_auth' => true, 'verify_ssl' => false, 'timeout' => 400, // curl timeout ] ); // product to create $product = array( 'name' => 'MAC PRO BOOK ZEND X MAN', 'regular_price' => '537.90', 'attributes' => array( array( 'name' => 'Color', // parameter for custom attributes 'visible' => true, // default: false 'variation' => true, 'options' => array( 'RED', 'BLUE' ) ))); // variant to send $data = [ 'regular_price' => '7.00', 'manage_stock' => true, 'stock_quantity' => 56, 'status' => 'publish', 'attributes' => [ [ 'name' => 'Color', 'option' => 'RED' ] ], ]; // post product $resp = $client->post('products', $product); // post product variations $data = $client->post('products/' + $resp->id + '/variations', $data); return $this->render('default/index.html.twig', [ 'controller_name' => 'DefaultController', ]); } }