Order button #1

Merged
nedimu merged 1 commits from order-button into master 2018-06-13 15:46:54 +02:00
6 changed files with 171 additions and 2447 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2207,6 +2207,27 @@
"sha.js": "^2.4.8"
}
},
"cross-fetch": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-2.2.1.tgz",
"integrity": "sha1-lshZEE113vyWf7XbYkdOdUJrArA=",
"requires": {
"node-fetch": "2.1.2",
"whatwg-fetch": "2.0.4"
},
"dependencies": {
"node-fetch": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz",
"integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U="
},
"whatwg-fetch": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz",
"integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng=="
}
}
},
"cross-spawn": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
@@ -4677,6 +4698,11 @@
"minimalistic-crypto-utils": "^1.0.1"
}
},
"hoist-non-react-statics": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.0.tgz",
"integrity": "sha512-6Bl6XsDT1ntE0lHbIhr4Kp2PGcleGZ66qu5Jqk8lc0Xc/IeG6gVLmwUGs/K0Us+L8VWoKgj0uWdPMataOsm31w=="
},
"home-or-tmp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz",
@@ -6431,6 +6457,11 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
"integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
},
"lodash-es": {
"version": "4.17.10",
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.10.tgz",
"integrity": "sha512-iesFYPmxYYGTcmQK0sL8bX3TGHyM6b2qREaB4kamHfQyfPJP0xgoGxp19nsH16nsfquLdiyKyX3mQkfiSGV8Rg=="
},
"lodash._reinterpolate": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz",
@@ -6957,6 +6988,11 @@
"resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.4.4.tgz",
"integrity": "sha512-3iuY4N5dhgMpCUrOVnuAdGrgxVqV2cJpM+XNccjR2DKOB1RUP0aA+wGXEiNziG/UKboFyGBIoKOaNlJxx8bciQ=="
},
"oauth-1.0a": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/oauth-1.0a/-/oauth-1.0a-2.2.4.tgz",
"integrity": "sha512-qHqZLUIcd+mrOKYMFosi9lC0KW602BeLdJ660M3MNhT7WruzFSgJbFZE5sdN+nV55Xk/ls9k1FusaCiDItli1g=="
},
"oauth-sign": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
@@ -8819,6 +8855,19 @@
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-4.0.0.tgz",
"integrity": "sha512-FlsPxavEyMuR6TjVbSSywovXSEyOg6ZDj5+Z8nbsRl9EkOzAhEIcS+GLoQDC5fz/t9suhUXWmUrOBrgeUvrMxw=="
},
"react-redux": {
"version": "5.0.7",
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-5.0.7.tgz",
"integrity": "sha512-5VI8EV5hdgNgyjfmWzBbdrqUkrVRKlyTKk1sGH3jzM2M2Mhj/seQgPXaz6gVAj2lz/nz688AdTqMO18Lr24Zhg==",
"requires": {
"hoist-non-react-statics": "^2.5.0",
"invariant": "^2.0.0",
"lodash": "^4.17.5",
"lodash-es": "^4.17.5",
"loose-envify": "^1.1.0",
"prop-types": "^15.6.0"
}
},
"read-pkg": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
@@ -8941,6 +8990,15 @@
}
}
},
"redux": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/redux/-/redux-4.0.0.tgz",
"integrity": "sha512-NnnHF0h0WVE/hXyrB6OlX67LYRuaf/rJcbWvnHHEPCF/Xa/AZpwhs/20WyqzQae5x4SD2F9nPObgBh2rxAgLiA==",
"requires": {
"loose-envify": "^1.1.0",
"symbol-observable": "^1.2.0"
}
},
"regenerate": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz",
@@ -9957,6 +10015,11 @@
"serviceworker-cache-polyfill": "^4.0.0"
}
},
"symbol-observable": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="
},
"symbol-tree": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",
@@ -11056,6 +11119,16 @@
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz",
"integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0="
},
"woocommerce-api": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/woocommerce-api/-/woocommerce-api-1.4.2.tgz",
"integrity": "sha1-/fe5Hip+EQjqAHxQ4qexPRJ1xAw=",
"requires": {
"bluebird": "^3.4.6",
"oauth-1.0a": "^2.0.0",
"request": "^2.75.0"
}
},
"wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",

View File

@@ -12,6 +12,7 @@
"babel-runtime": "6.26.0",
"case-sensitive-paths-webpack-plugin": "2.1.1",
"chalk": "1.1.3",
"cross-fetch": "^2.2.1",
"css-loader": "0.28.7",
"dotenv": "4.0.0",
"dotenv-expand": "4.2.0",
@@ -35,6 +36,8 @@
"react": "^16.4.0",
"react-dev-utils": "^5.0.1",
"react-dom": "^16.4.0",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"resolve": "1.6.0",
"style-loader": "0.19.0",
"sw-precache-webpack-plugin": "0.11.4",
@@ -42,7 +45,8 @@
"webpack": "3.8.1",
"webpack-dev-server": "2.9.4",
"webpack-manifest-plugin": "1.3.2",
"whatwg-fetch": "2.0.3"
"whatwg-fetch": "2.0.3",
"woocommerce-api": "^1.4.2"
},
"scripts": {
"start": "node scripts/start.js",

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