Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / wc-add-custom-tab.php
Created February 1, 2021 14:30 — forked from woogists/wc-add-custom-tab.php
[Frontend Snippets][Editing product data tabs] Add a custom tab
/**
* Add a custom product data tab
*/
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __( 'New Product Tab', 'woocommerce' ),
@dexit
dexit / wc-add-additional-information.php
Created February 1, 2021 14:30 — forked from woogists/wc-add-additional-information.php
[Frontend Snippets][Editing product data tabs] Add additional information
/**
* Check if product has attributes, dimensions or weight to override the call_user_func() expects parameter 1 to be a valid callback error when changing the additional tab
*/
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product;
if( $product->has_attributes() || $product->has_dimensions() || $product->has_weight() ) { // Check if product has attributes, dimensions or weight
@dexit
dexit / wc-remove-tabs.php
Created February 1, 2021 14:34 — forked from woogists/wc-remove-tabs.php
[Frontend Snippets][Editing product data tabs] Remove product data tabs
/**
* Remove product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
@dexit
dexit / wc-automatically-complete-orders.php
Created February 1, 2021 14:34
[Frontend Snippets] Automatically complete all orders
/**
* Auto Complete all WooCommerce orders.
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
@dexit
dexit / wc-custom-tracking-code-for-thanks-page.php
Created February 1, 2021 14:34 — forked from woogists/wc-custom-tracking-code-for-thanks-page.php
[Frontend Snippets] Custom tracking code for the thanks page
/**
* Add custom tracking code to the thank-you page
*/
add_action( 'woocommerce_thankyou', 'my_custom_tracking' );
function my_custom_tracking( $order_id ) {
// Lets grab the order
$order = wc_get_order( $order_id );
/* Woocommerce Styles */
/*
A couple things to note...
1. This code was written very specifically for my base child theme so it might not work out of the box with every theme.
I have it here mostly to share with anyone who might be looking to do the same thing I was.
2. I generally add my WooCommerce CSS overrides to a custom-woo.css file then use wp_enqueue_style() to call it
so that it enqueues after the default WooCommerce Stylesheets
@dexit
dexit / netlify-function.js
Created March 9, 2021 15:34 — forked from Maybach91/netlify-function.js
[gatsby + shopify + recurring payments] "instead of taking the user to shopify's checkout, you need to create a recharge's checkout. This can be only done from a server (backend) so you will either have to set one up or use serverless functions (I am using functions from netlify)." – https://github.com/blancomaberino - https://spectrum.chat/gats…
/* eslint-disable */
const fetch = require('node-fetch')
const rechargeToken = process.env.RECHARGE_TOKEN
const subscriptionIntervalFrequency = process.env.SUBSCRIPTION_INTERVAL_FREQUENCY || 30
const subscriptionIntervalUnit = process.env.SUBSCRIPTION_INTERVAL_UNIT || 'day'
/**
* Builds request headers
* @return {Array}
*/
const buildHeaders = () => ({
@dexit
dexit / wpa-clean-header.php
Created May 6, 2021 10:07 — forked from Auke1810/wpa-clean-header.php
create a clean wordpress header and remove unnecessary clutter.
<?php
/*
Plugin Name: wordpress assist clean header
Plugin URI: http://www.wordpressassist.nl/
Description: Remove shortlink hook
Version: 1.0
Author: AukeJomm
Author URI: http://www.aukejongbloed.nl
*/
@dexit
dexit / functions.php
Created May 6, 2021 12:31 — forked from LukaHarambasic/functions.php
Wordpress: ACF-Field as CPT Title
// inspired by: https://gist.github.com/rveitch/9018669face1686e74aaa68026856f36
// add title to CPTs which doesn't provide a title (useful for the relationship field (https://www.advancedcustomfields.com/resources/relationship/))
function sync_acf_post_title($post_id, $post, $update) {
$post_type = get_post_type($post_id);
// check for the current CPT
if($post_type === "cpt_name_1") {
@dexit
dexit / functions.php
Created May 21, 2021 11:08 — forked from offroadkev/functions.php
Change Gravity Forms Spinner to CSS Spinner
// Changes Gravity Forms Ajax Spinner (next, back, submit) to a transparent image
// this allows you to target the css and create a pure css spinner like the one used below in the style.css file of this gist.
add_filter( 'gform_ajax_spinner_url', 'spinner_url', 10, 2 );
function spinner_url( $image_src, $form ) {
return 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; // relative to you theme images folder
}