Skip to content

Instantly share code, notes, and snippets.

View darrylmorley's full-sized avatar

Darryl Morley darrylmorley

View GitHub Profile
@darrylmorley
darrylmorley / woocommerce-snippets
Created October 11, 2019 13:48
Disable Sales & Buy Button #woocommerce
//* Disable Purchases
add_filter( 'woocommerce_is_purchasable', '__return_false');
@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 / 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-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 / 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) {
Dockerfile changes:
# Install dependencies only when needed
FROM node:14-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock ./
**COPY ./prisma/schema.prisma ./prisma/schema.prisma**
RUN yarn install --frozen-lockfile
@darrylmorley
darrylmorley / gist:a013734967a0fa6cb46e7c9674016c29
Created October 1, 2021 06:46
Portainer Traefik Labels Example
"traefik.enable=true"
"traefik.docker.network=proxy"
"traefik.http.routers.app-secure.entrypoints=websecure"
"traefik.http.routers.app-secure.rule=Host(`domain.name`)"
@darrylmorley
darrylmorley / js-dynamic-form
Created October 20, 2021 09:44
Create form dynamically
// Create a form synamically
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "submit.php");
// Create an input element for Full Name
var FN = document.createElement("input");
FN.setAttribute("type", "text");
FN.setAttribute("name", "FullName");
FN.setAttribute("placeholder", "Full Name");

docker history --human --format "{{.CreatedBy}}: {{.Size}}" docker-image

Set a default Layout - Inertia / Vue

createInertiaApp({
  resolve: (name) => {
    let page = resolvePageComponent(
			`./Pages/${name}.vue`,
			import.meta.glob('./Pages/**/*.vue')
    );
 page.then((module) =&gt; {