Skip to content

Instantly share code, notes, and snippets.

View gonzalesc's full-sized avatar

Alexander gonzalesc

View GitHub Profile
@gonzalesc
gonzalesc / fullculqi_force_language.php
Created October 29, 2019 17:12
Force Language in Culqi Integration
<?php
if( !function_exists('letsgo_culqi_force_language') ) {
function letsgo_culqi_force_language($language = 'es') {
return 'es'; //"es" or "en"
}
add_filter('fullculqi/global/language', 'letsgo_culqi_force_language', 10, 1);
}
@gonzalesc
gonzalesc / customize_price_range_format.php
Created December 16, 2024 18:32
Modify the price range format on the variable product
<?php
/**
* Modify the price range format on the product page
* @package LetsGodev\MuPlugins
* @since 1.0
*/
add_filter( 'woocommerce_get_price_html', 'priceRangeFormat', 10, 2 );
/**
@gonzalesc
gonzalesc / send_php_to_js.php
Created December 17, 2024 16:58
Send PHP variables to script JS
<?php
/**
* Send php variables to js
* @package LetsGodev\MuPlugins
* @since 1.0
* @description : use letsgo_vars.ajax_url in script js
*/
add_action( 'wp_enqueue_scripts', 'sendVarsToScripts' );
@gonzalesc
gonzalesc / tie_down_authors.php
Created December 20, 2024 18:38
Tie down authors to see only their own posts on WordPress
<?php
/**
* Tie down authors to see only their own posts
* @package LetsGodev\MuPlugins
* @since 1.0.0
*/
add_filter( 'pre_get_posts', 'tieDownAuthors' );
/**
* Tie down authors to see only their own posts
@gonzalesc
gonzalesc / new_basic_custom_plugin.php
Created December 22, 2024 19:53
New Custom Plugin - Example plugin
<?php
/**
* @link https://www.letsgodev.com/
* @since 1.0.0
* @package Plugins/LetsGoDev/PluginExample
*
* Plugin Name: Plugin Example
* Plugin URI: https://www.letsgodev.com/
* Description: This plugin is an example
* Version: 1.0.0
@gonzalesc
gonzalesc / set_minimum_order_example_plugin.php
Created December 22, 2024 19:57
Example plugin - Set mininum order in WooCommerce
<?php
/**
* @link https://www.letsgodev.com/
* @since 1.0.0
* @package Plugins/LetsGoDev/PluginExample
*
* Plugin Name: Set minimum order
* Plugin URI: https://www.letsgodev.com/
* Description: This plugin is an example
* Version: 1.0.0
@gonzalesc
gonzalesc / free_shipping_by_subtotal.php
Created January 5, 2025 10:18
Free Shipping method by Subtotal in WooCommerce
<?php
/*********
* Hooks
* Remember to remove shipping-transient-version transient
********/
// Snippet 1 : Hide other shipping methods
add_filter( 'woocommerce_package_rates', 'maybeFreeShipping' );
// Snippet 2 : Notify that the customer can access free shipping.
@gonzalesc
gonzalesc / convert_wc_in_catalog_mode.php
Created January 19, 2025 08:13
Convert your WooCommerce in catalog mode
<?php
/**
* Convert your Ecommerce in catalog mode
* @package LetsGodev\MuPlugins
* @since 1.0
*/
// Hide the cart page & checkout page
add_action( 'template_redirect', 'hideCartCheckoutPage' );
@gonzalesc
gonzalesc / addProductCustomFileds.php
Created January 23, 2025 18:32
How to add product custom fields in WooCommerce
<?php
/******************
* Product Hooks
******************/
// Print a product custom field
add_action( 'woocommerce_before_add_to_cart_button', 'printProductCustomFields' );
/***************
* Cart Hooks
***************/
@gonzalesc
gonzalesc / wc-create-user-moodle.php
Created January 28, 2025 04:35
Create an user Moodle when the payment is completed in WooComerce
<?php
/**
* Payment Complete in WC
*/
add_action( 'woocommerce_payment_complete', 'createMoodleUser' );
/**
* Create Moodle User
* @param int $orderID