Skip to content

Instantly share code, notes, and snippets.

@swoboda
swoboda / functions.php
Last active January 16, 2019 16:03
AutomateWoo - Custom Subscription Rule based on Parent Order Status
<?php
// Do NOT include the opening php tag
add_filter( 'automatewoo/rules/includes', 'wpdesk_automatewoo_rules' );
/**
* Custom Rules
*
*/
function wpdesk_automatewoo_rules( $rules ) {
@swoboda
swoboda / remove-related-products.php
Created April 13, 2018 13:24
Remove related products from WooCommerce single product page
@swoboda
swoboda / fcf-custom-validation-length.php
Created April 11, 2018 16:31
Custom Min/Max Character Limit Validation for WooCommerce Flexible Checkout Fields
<?php
// Do NOT include the opening php tag
/**
* Function to validate the length
*
*/
function wpdesk_fcf_validate_length( $field_label, $value ) {
$min_length = 3;
$max_length = 20;
@swoboda
swoboda / fcf-custom-validation-url.php
Created April 11, 2018 16:27
Custom URL Validation for WooCommerce Flexible Checkout Fields
<?php
// Do NOT include the opening php tag
/**
* Function to validate the URL
*
*/
function wpdesk_fcf_validate_url( $field_label, $value ) {
if ( filter_var( $value, FILTER_VALIDATE_URL ) == false ) {
wc_add_notice( sprintf( '%s is not a valid URL.', '<strong>' . $field_label . '</strong>' ), 'error' );
@swoboda
swoboda / fcf-custom-validation-number.php
Created April 11, 2018 16:24
Custom Number Validation for WooCommerce Flexible Checkout Fields
<?php
// Do NOT include the opening php tag
/**
* Function to validate the number
*
*/
function wpdesk_fcf_validate_number( $field_label, $value ) {
if ( ! ( ( is_numeric( $value ) ? intval( $value ) == $value : false ) ) ) {
wc_add_notice( sprintf( '%s is not a valid number.', '<strong>' . $field_label . '</strong>' ), 'error' );
@swoboda
swoboda / woocommerce-payment-status-note.php
Created March 28, 2018 13:47
woocommerce-payment-status-note
<?php
// Do NOT include the opening php tag
add_filter( 'woocommerce_payment_status_note', 'wpdesk_payment_status_note' );
/**
* Change order note for WooCommerce Automatic Payment Status
*
*/
function wpdesk_payment_status_note() {
return 'Order completed. Yeah!';
@swoboda
swoboda / go2cloud.php
Created March 22, 2018 08:47
go2cloud.php
<!– Offer Conversion: cps test 5 –>
<img src="xyz.go2cloud.org/aff_l?offer_id=2141&amount=<?php echo $order->get_total(); ?>" width="1" height="1" />
<!– // End Offer Conversion –>
@swoboda
swoboda / add-inline-js.php
Created March 19, 2018 10:41
add-inline-js.php
<?php
// Do NOT include the opening php tag
add_action( 'wp_head', 'wpdesk_custom_js' );
// Add inline JS
function wpdesk_custom_js() {
echo <<<JS
<script type="text/javascript">
// Add your JS here
</script>
@swoboda
swoboda / disable-translation-updates.php
Last active September 6, 2023 09:06 — forked from r-a-y/bp-disable-translation.php
Disable automatic plugins translations by WordPress.org.
<?php
/*
Plugin Name: Disable Translation Updates
Description: Disables automatic plugins translations by WordPress.org.
Author: wpdesk
License: GPLv2 or later
*/
add_filter( 'auto_update_translation', 'wpdesk_disable_translation_updates', 10, 2 );
/**
@swoboda
swoboda / woocommerce-cart-hooks-add.php
Created November 6, 2017 17:53
Add "Free Shipping" text to WooCommerce cart page. Complete visual WooCommerce cart hooks guide: https://www.wpdesk.net/blog/woocommerce-cart-hooks/
<?php
// Do NOT include the opening php tag
add_action( 'woocommerce_before_cart_table', 'wpdesk_cart_free_shipping_text' );
/**
* Add "free shipping" text to WooCommerce cart page
*
*/
function wpdesk_cart_free_shipping_text() {
echo '<div class="woocommerce-info">Free Shipping available from $299!</div>';