Skip to content

Instantly share code, notes, and snippets.

View darrylmorley's full-sized avatar

Darryl Morley darrylmorley

View GitHub Profile
@darrylmorley
darrylmorley / 401Interceptor.js
Last active August 1, 2020 22:41
Axios response interceptor for handling http 401 errors & dealing with token refresh. #javascript
axios.interceptors.response.use(function(response) {
return response;
}, async function(error) {
await new Promise(function(res) {
setTimeout(function() {res()}, 10000);
});
const originalRequest = error.config;
if (error.response.status===401 && !originalRequest._retry) {
@darrylmorley
darrylmorley / woo-product-import.php
Last active August 1, 2020 22:42
Woocommerce Product Import
<?php
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
use Automattic\WooCommerce\HttpClient\HttpClientException;
function getWoocommerceConfig()
{
$woocommerce = new Client(
'https://www.dbogarin.com',
'ck_6df71ec5e7d1f63df2a5a08101fcefdcf67a4b51',
'cs_cff7aaed1533c3efc88514ad87d503a8727a423a',
@darrylmorley
darrylmorley / delete-crud-woo.php
Last active August 1, 2020 22:42
Delete Object Using CRUD #woocommerce
<?php
/**
* Delete an object, set the ID to 0, and return result.
*
* @param bool $force_delete
* @return bool result
*/
public function delete( $force_delete = false ) {
// Trigger action before deleting from DB. Allows you to adjust some related object props before delete.
do_action( 'woocommerce_before_' . $this->object_type . '_object_delete', $this, $this->data_store );
@darrylmorley
darrylmorley / woo-css.css
Last active August 1, 2020 22:43
Woocommerce CSS #woocommerce #css
/*----------------------------------------------------------------------------------
TABLE OF CONTENT
1. Reset
2. General Styling (default font, color, lists, headings, form elements, etc.)
3. Structure (page width & layout containers)
4. Grid (column width)
5. Header (logo, tagline, social widget, search form, main menu)
6. Page (page title, author page, pagination)
7. Post (post layouts & styling, comments, post navigation)
@darrylmorley
darrylmorley / woocommerce-snippets
Created October 11, 2019 13:48
Disable Sales & Buy Button #woocommerce
//* Disable Purchases
add_filter( 'woocommerce_is_purchasable', '__return_false');