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 / 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: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: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;
/**
* @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 / 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;
@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
*/
[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 / 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;
}
@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'