Added send order button

This commit is contained in:
Nedim Uka
2018-06-12 13:42:45 +02:00
parent afcf7a3a91
commit 4e52521fae
6 changed files with 171 additions and 2447 deletions

View File

@@ -1,19 +1,20 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { Order } from './components';
import { sendOrder } from './actions';
const onOrderClicked = function () {
return sendOrder()
}
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
<div className="App">
<Order onOrderClicked={onOrderClicked} />
</div>
);
}
}

View File

@@ -0,0 +1,57 @@
var WooCommerceAPI = require('woocommerce-api');
export const SEND_ORDER = 'SEND_ORDER'
var WooCommerce = new WooCommerceAPI({
url: 'https://localhost',
consumerKey: 'ck_79837fb6f49f9f3eca830e34faeeea35b6cc1287',
consumerSecret: 'cs_18bd03a0e6afd7d5c9e51e1d1c86032e425bd8d8',
wpAPI: true,
version: 'wc/v2',
});
export function sendOrder() {
var 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
}
]
};
WooCommerce.post('orders', data, function(err, data, res) {
console.log(res);
});
}

View File

@@ -0,0 +1,10 @@
import React from 'react'
export const Order = (props) => {
return (
<button onClick={props.onOrderClicked} > SEND ORDER </button>
)
}
export default Order