Skip to content

Instantly share code, notes, and snippets.

Avatar

Olaf Lederer finalwebsites

View GitHub Profile
@finalwebsites
finalwebsites / bedankpagina.php
Created April 20, 2023 18:15
WooCommerce: Redirect the customer to your own thank you page (one for successful payments and one for all other statuses)
View bedankpagina.php
<?php
add_action( 'woocommerce_thankyou', 'fw_redirect_custom_thank_you_page');
function fw_redirect_custom_thank_you_page( $order_id ){
$order = wc_get_order( $order_id );
$url = home_url('/YOUR_THANK_YOU_PAGE/'); // <<< change this slug
if ( $order->has_status( array('processing', 'completed' ) ) ) {
wp_safe_redirect( $url );
exit;
}
}
@finalwebsites
finalwebsites / functions.php
Created April 16, 2023 13:18
Child theme for WordPress
View functions.php
<?php
add_action( 'wp_enqueue_scripts', 'fw_theme_enqueue_styles', 100 );
function fw_theme_enqueue_styles() {
$dependencies = array(); // add here other theme handles, for example from the parent theme or WooCommerce
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', $dependencies, '1.0.0' );
}
@finalwebsites
finalwebsites / woocommerce_archive_description.php
Last active April 15, 2023 14:25
WooCommerce hooks example codes
View woocommerce_archive_description.php
<?php
// remove the category description above the product list
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
// add the category description below the product list
add_action( 'woocommerce_after_shop_loop', 'woocommerce_taxonomy_archive_description', 100 );
@finalwebsites
finalwebsites / functions.php
Created April 9, 2023 15:52
Add aan extra description to your WooCommerce product archive with ACF
View functions.php
<?php
/*
Place this code in your functions.php file
to show a second description at the end of your
product categorie archive.
Disclaimer: Use this code snippet ith extreme care and at your own risk.
*/
add_action('woocommerce_after_shop_loop', function() {
@finalwebsites
finalwebsites / woocommerce_merken.php
Last active April 8, 2023 10:09
Merken functionaliteit voor WooCommerce, met en zonder Elementor
View woocommerce_merken.php
<?php
/*
Copy/paste deze code in het functions.php bestand van je child theme.
Disclaimer:
Afhankelijk van je website instellingen is het mogelijk
dat deze code niet werkt of zelfs een storing in je website oproept.
Het gebruik van deze code gebeurd op eigen risico!
*/
@finalwebsites
finalwebsites / getinvoicelist.php
Created December 30, 2022 09:15
EFD getinvoicelist
View getinvoicelist.php
<?php
function getInvoices($contact, $page = 0) {
global $link, $api, $today, $year_ago;
$filters = array(
'contact_id' => $contact,
'is_sent' => 1,
'invoice_date' => array($year_ago, $today)
);
//print_r($filters);
@finalwebsites
finalwebsites / Bestaande_klanten.php
Last active December 18, 2022 11:28
WooCommerce code voorbeelden voor de integratie met Clicky Analytics
View Bestaande_klanten.php
<?php
add_action('wp_footer', 'fw_get_user_for_clicky');
function fw_get_user_for_clicky() {
$current_user = wp_get_current_user();
if ( $current_user->exists() ) {
// Vraag je klant/gebruiker eerst om toestemming voordat je deze code toont
echo '
<script type="text/javascript">
var clicky_custom = clicky_custom || {};
clicky_custom.visitor = {
@finalwebsites
finalwebsites / functions.php
Last active October 5, 2022 07:06
WordPress - remove the comment author URL field
View functions.php
<?php
// add this code snippet to your child theme's functions.php file
add_filter('comment_form_default_fields', 'fw_remove_comment_author_url');
function fw_remove_comment_author_url($fields) {
if (isset($fields['url'])) {
unset($fields['url']);
}
return $fields;
}
@finalwebsites
finalwebsites / .htaccess
Created September 3, 2022 06:52
Ignore missing files and report a 404 status
View .htaccess
# add this code to your .htaccess file (Apache based servers only)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|png|gif|bmp|ico|css|js|swf|htm|html|txt|php|asp|aspx)$ [NC]
RewriteRule .* - [L,R=404]
</IfModule>
@finalwebsites
finalwebsites / mysql_db_backup.sh
Last active August 28, 2022 10:04
Create daily backups from your MySQL databases (simple script)
View mysql_db_backup.sh
#!/bin/sh
# Find out what databases are in mysql and back them up
# Delete old backups
STARTTIME=` date +%Y%m%d-%H%M `
BACKUP_DIR="/srv/users/serverpilot/apps/backups"
LOGFILE="/srv/users/serverpilot/apps/backups/db_backup.log"
USER="root"
PASSWD="ENTER_ROOT_PASSWORD"
KEEP="20"