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
[options]
#
# WARNING:
# If you use the Odoo Database utility to change the master password be aware
# that the formatting of this file WILL be LOST! A copy of this file named
# /etc/odoo/openerp-server.conf.template has been made in case this happens
# Note that the copy does not have any first boot changes
#-----------------------------------------------------------------------------
# Odoo Server Config File - TurnKey Linux
@codeagencybe
codeagencybe / gist:b2bb9076782d6d8ac9af66f5c4fd0e65
Created February 7, 2019 12:38
Hide other shipping methods when free shipping is available
/**
* Hide shipping rates and methods when free shipping is available.
* Updated to support WooCommerce 2.6+ Shipping Zones.
*
* Author: Fabio Tielen / Code Agency
* URL: https://codeagency.be
*
* @param array $rates Array of rates found for the package.
* @return array
*/
@codeagencybe
codeagencybe / ca_message_no_available_shipping_methods.php
Created October 27, 2018 13:03
Woocommerce change message when no delivery method is available
add_filter( 'woocommerce_cart_no_shipping_available_html', 'ca_message_no_available_shipping_methods', 10, 1 );
add_filter( 'woocommerce_no_shipping_available_html', 'ca_message_no_available_shipping_methods', 10, 1 );
function ca_message_no_available_shipping_methods( $default_msg ) {
$custom_msg = "Unfortunately, our delivery service is available in your location";
if( empty( $custom_msg ) ) {
return $default_msg;
}
return $custom_msg;
/**
* @snippet Custom Checkout Fee for WooCommerce
* @author Fabio Tielen / Code Agency / https://codeagency.be
* @compatible WooCommerce 3.4.5
*/
// Display Buttons
// Uses woocommerce_form_field()
add_action( 'woocommerce_review_order_before_payment', 'ca_checkout_radio_choice' );
@codeagencybe
codeagencybe / gist:92a7e2330e33cfde022b7749569d89d7
Created September 8, 2018 10:09 — forked from teodorboev/gist:c3f125c1fd8b2b829d99672c0d686362
Wordpress MySQL table converter to InnoDB
DROP PROCEDURE IF EXISTS convertToInnodb;
DELIMITER //
CREATE PROCEDURE convertToInnodb()
BEGIN
mainloop: LOOP
SELECT TABLE_NAME INTO @convertTable FROM information_schema.TABLES
WHERE `TABLE_SCHEMA` LIKE DATABASE()
AND `ENGINE` LIKE 'MyISAM' ORDER BY TABLE_NAME LIMIT 1;
IF @convertTable IS NULL THEN
LEAVE mainloop;
@codeagencybe
codeagencybe / gist:75352fb620af33dac83226c0311c14e1
Last active November 11, 2018 10:45
Show custom badge text per product on single product page and archive page
/**
* @snippet Show custom information on product single page and archive page
* @website https://codeagency.be
* @author Code Agency / Fabio Tielen / [email protected]
* @testedwith WooCommerce 3.4.4
*/
// -----------------------------------------
// 1. Add new text field to product edit page (General tab)
@codeagencybe
codeagencybe / gist:6fdfb4247f4e0c16a65fa3064844a9d3
Created August 19, 2018 23:26
WooCommerce import with WP CLI
#!/bin/bash
echo -e "Importing products now!"
OLDIFS=$IFS
while IFS='|' read -r sku images product_title short_description cats weight regular_price stock_qty manage_stock length height width
do
DIMS=({\"length\":\"${length}\"\,\"width\":\"${width}\"\,\"height\":\"${height}\"})
echo ${DIMS[@]}
@codeagencybe
codeagencybe / gist:7a7429334fa504338e45812601dc53a3
Last active August 4, 2018 09:45
WooCommerce order step values
/**
* @description Minimum, maximum, incremental and start quantity for products | WooCommerce
* @author Fabio Tielen / Code Agency / https://codeagency.be
* @testedwith WooCommerce 3.3
*/
add_filter( 'woocommerce_quantity_input_args', 'ca_woocommerce_quantity_increment_changes', 10, 2 );
function ca_woocommerce_quantity_increment_changes( $args, $product ) {
if ( is_singular( 'product' ) ) {
@codeagencybe
codeagencybe / gist:a1542fbc5b25cbb295be910afbf15f73
Created July 9, 2018 12:18
automatically add product to cart when cart total is above certain amount
/**
* @snippet Automatically add a specific product to cart when cart amount is above certain amount
* @author Fabio Tielen // Code Agency // https://codeagency.be
* @testedwith Woo 3.3+
*/
add_action( 'template_redirect', 'codeagency_add_product_to_cart' );
function codeagency_add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;