zulzahid
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [WooCommerce] [API Issue] Unable to create a new product via app.controller('AddProductCtrl',function($scope,$localStorage, $ionicHistory, $ionicPopup,WC, $state){ $scope.newProduct = {}; $scope.prodCategories = [ { type: "simple"}, { type: "grouped"}, { type: "external"} ]; $scope.productNewData = {}; $scope.addNewProduct = function(newProduct){ var data = { title: newProduct.name, type: newProduct.newProductType, regular_price: newProduct.regular_price, description: newProduct.description, short_description: newProduct.short_description, categories: [{id:newProduct.categories}, {id: newProduct.categoriesSub}], images: [ { src: 'https://example.com/wp-content/uploads/2015/01/premium-quality-front.jpg', position: 0, title:'Notebook', alt: 'Notebook' }, { src: 'https://example.com/wp-content/uploads/2015/01/premium-quality-back.jpg', position: 1, title:'Notebook', alt: 'Notebook' } ]}; var productData = {}; productData.productBaru = data; var Woocommerce = WC.WC(); Woocommerce.post('products',productData, function(err, data, res){ if(err){ console.log(err); } console.log(JSON.parse(res)); if(JSON.parse(res).productBaru){ $ionicPopup.show({ title: "Congratulations", template: "Product has been created succesfully.", buttons: [{ text: "Check", type: "button-assertive", onTap: function(e){ $state.go('app.browse'); } }] }) } else{ $ionicPopup.show({ title: "OOPS", template: JSON.parse(res).errors[0].message, buttons: [{ text: "OK", type: "button-assertive" }] }) } }); } })
<ion-view view-title="AddProduct"> <div class="bar bar-subheader bar-positive"> <h1 class="title">Product Information</h1> </div> <ion-content class="has-subheader padding"> <div class="list list-inset"> <div class="item item-divider"> Product Information </div> <label class="item item-input"> <span class="input-label">Product Name</span> <input type="text" ng-model="newProduct.name"> </label> <label class="item item-input"> <span class="input-label">Regular Price</span> <input type="text" ng-model="newProduct.regular_price"> </label> <label class="item item-input"> <span class="input-label">Description</span> <input type="text" ng-model="newProduct.description"> </label> <label class="item item-input"> <span class="input-label">Short Description</span> <input type="text" ng-model="newProduct.short_description"> </label> <label class="item item-input item-select"> <span class="input-label">Product Category Type</span> <select ng-model="newProduct.newProductType"> <option selected >simple</option> <option>grouped</option> <option>external</option> <option>variable</option> </select> </label> <label class="item item-input item-select"> <span class="input-label">Product Categories</span> <select ng-model="newProduct.categories" > <option selected >0</option> <option>1</option> <option>2</option> <option>3</option> </select> </label> <label class="item item-input item-select"> <span class="input-label">Product Categories Sub</span> <select ng-model="newProduct.categoriesSub" > <option selected >0</option> <option>1</option> <option>2</option> <option>3</option> </select> </label> <div class="item item-divider"> Product Picture </div> <div class="button-bar"> <button class="button button-assertive button-block button-outline">Cancel</button> <button class="button button-assertive button-block" ng-click="addNewProduct(newProduct)">Add Product</button> </div> </div> </ion-content> </ion-view>
can u help me on this. i already post in suport pages but the post are no where to befound.
im unable to create product through rest apii got this error when i send data to the server
code:”woocommerce_api_missing_product_data”
message:”No product data specified to create product”[Moderator Note: Please don’t post huge chunks of code here. Use pastebin.com or gist.github.com and put the links here. Your posts got caught in the spam filters due to their length and other mysterious things the spam filters do.]
- This reply was modified 8 years, 2 months ago by zulzahid.
- This reply was modified 8 years, 2 months ago by Steven Stern (sterndata).
Viewing 1 replies (of 1 total)