even though I hard coded my customer key and secret key ,
it return error saying woocommerce_rest_cannot_view
I tried on my real device . but saying same
Failed to load resource: the server responded with a status of 401 ()
How can I create new order with http request…
const data = {
payment_method: "bacs",
payment_method_title: "Direct Bank Transfer",
set_paid: true,
billing: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe@example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
},
line_items: [
{
product_id: 93,
quantity: 2
},
{
product_id: 22,
variation_id: 23,
quantity: 1
}
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: 10
}
]
};
const orderObj = {};
orderObj['payment_method'] = data.payment_method
orderObj['payment_method_title'] = data.payment_method_title
orderObj['customer_id'] = this.filter.customer_id
orderObj['billing'] = data.billing
orderObj['shipping'] = data.shipping
orderObj['line_items'] = data.line_items
const headers = new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded'
});
return new Promise(resolve => {
this.http
.post(
"https://www.dentpro.shop/wp-json/wc/v3/orders/?consumer_key="+"ck_85f5d88dd29b348e373ab5f31d40608xxxxxxx"+"'&consumer_secret=cs_1e33534bae4f4fbc0e19762864bxxxxxx",
orderObj,
{ headers }
)
.subscribe(data => {
console.log("data is : ");
console.log(data);
resolve(data);
});
});