Skip to content

Instantly share code, notes, and snippets.

View codeagencybe's full-sized avatar
🏠
Working from home

Fabio Tielen codeagencybe

🏠
Working from home
View GitHub Profile
@codeagencybe
codeagencybe / _SR_DB.mk
Created March 21, 2021 20:53 — forked from lopadz/SYNC_GIST_README.md
Sync WP Code & DB Makefile Recipe
# Specify the shell
SHELL := bash
# Site URL
OLD_URL = https://domain.test
NEW_URL = https://www.domain.com
# Commands to execute
execute:
@codeagencybe
codeagencybe / setup-k3s-on-hetzner.sh
Created August 17, 2020 14:20 — forked from alexanderkjeldaas/setup-k3s-on-hetzner.sh
Setup k3s on Hetzner with CSI drivers
#!/bin/bash
LOCATION=${HCLOUD_LOCATION:-nbg1-dc3}
if [ -z "$HCLOUD_TOKEN" ]; then
echo "You need to set HCLOUD_TOKEN to an Hetzner API token!";
exit 1
fi
if [ -z "$SSH_KEY" ]; then
@codeagencybe
codeagencybe / custom_fields_category
Created August 10, 2020 20:17
custom fields woocommerce category
// Add term page
function codeagency_taxonomy_add_new_meta_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="term_meta[en_translation]"><?php _e( 'en_translation', 'codagency' ); ?></label>
<input type="text" name="term_meta[en_translation]" id="term_meta[en_translation]" value="">
</div>
<div class="form-field">
<label for="term_meta[fr_translation]"><?php _e( 'fr_translation', 'codagency' ); ?></label>
@codeagencybe
codeagencybe / codesnippet.php
Created July 14, 2020 15:08
split street/housenumber woocommerce
/*
Description: unset WooCommerce billing & shipping address_1 field in checkout in favor for 2 new custom fields street and houseno
Author: Code Agency
Author URI: https://codeagency.be
*/
function codeagency_remove_checkout_fields( $fields ) {
// Billing fields
// unset( $fields['billing']['billing_company'] );
// unset( $fields['billing']['billing_email'] );
@codeagencybe
codeagencybe / functions.php
Created April 28, 2020 09:48
WooCommerce Display out of stock variable products as unavailable
/**
* Disable out of stock variations
* https://github.com/woocommerce/woocommerce/blob/826af31e1e3b6e8e5fc3c1004cc517c5c5ec25b1/includes/class-wc-product-variation.php
* @return Boolean
* Description: unset WooCommerce billing & shipping address_1 field in checkout in favor for 2 new custom fields street and houseno
* Author: Code Agency
* Author URI: https://codeagency.be
*/
function codeagency_variation_is_active( $active, $variation ) {
<?php
/*
* Code snippet to make login form with Fluent Forms WordPress Plugins
* Steps:
* 1. make a form with email and password (Make sure the name attribute is 'email' and 'password' for corresponding field)
* 2. Paste the shorcode in a page
* 3. Change the form id in the bellow code (23) with your created fluentform's form id and paste in your theme's functions.php file
* 4. That's it
*
@codeagencybe
codeagencybe / custom-hooks.php
Created February 7, 2020 08:56 — forked from djrmom/custom-hooks.php
facetwp show/hide labels
<?php
add_action( 'wp_footer', function() {
?>
<script>
(function($) {
if ('object' !== typeof FWP) {
return;
}
$(function() {
@codeagencybe
codeagencybe / functions.php
Created December 9, 2019 23:21 — forked from maddisondesigns/functions.php
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@codeagencybe
codeagencybe / cloud-init.yaml
Created December 3, 2019 13:09 — forked from syntaqx/cloud-init.yaml
cloud init to install docker on ubuntu
#cloud-config
package_update: true
package_upgrade: true
package_reboot_if_required: true
manage-resolv-conf: true
resolv_conf:
nameservers:
- '8.8.8.8'
@codeagencybe
codeagencybe / discounts_programmatically.php
Created August 16, 2019 11:29
WooCommerce // Apply discounts programmatically
// Generating dynamically the product "regular price"
add_filter( 'woocommerce_product_get_regular_price', 'custom_dynamic_regular_price', 10, 2 );
add_filter( 'woocommerce_product_variation_get_regular_price', 'custom_dynamic_regular_price', 10, 2 );
function custom_dynamic_regular_price( $regular_price, $product ) {
if( empty($regular_price) || $regular_price == 0 )
return $product->get_price();
else
return $regular_price;
}