Skip to content

Instantly share code, notes, and snippets.

:shipit:

Claudio Sanches claudiosanches

:shipit:
Block or report user

Report or block claudiosanches

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@claudiosanches
claudiosanches / functions.php
Created May 11, 2016
WooCommerce - Use "Starting at" prefix for variable price range
View functions.php
<?php
/**
* Custom variable price HTML.
* Shows "Starting at" prefix with when min price is different from max price.
*
* @param stirng $price Product price HTML
* @param WC_Product_Variable $product Product data.
* @return string
*/
function cs_my_wc_custom_variable_price_html( $price, $product ) {
@claudiosanches
claudiosanches / django-runserver-ssl.md
Last active Jan 21, 2020
Django - SSL with runserver
View django-runserver-ssl.md

Instalation

[sudo] apt-get install stunnel

Configuration

cd path/to/django/project
@claudiosanches
claudiosanches / test.php
Last active Jan 16, 2020
Regex for test credit card brand
View test.php
<?php
// Test cards
$cards = array(
'378282246310005', // American Express
'371449635398431', // American Express
'5078601870000127985', // Aura
'5078601800003247449', // Aura
'30569309025904', // Diners Club
'38520000023237', // Diners Club
@claudiosanches
claudiosanches / functions.php
Last active Jan 16, 2020
WooCommerce - Change ajax variation threshold
View functions.php
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return 10;
}
add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );
@claudiosanches
claudiosanches / functions.php
Last active Dec 14, 2019
WooCommerce - Add Order Again button to My Orders actions
View functions.php
<?php
/**
* Add order again button in my orders actions.
*
* @param array $actions
* @param WC_Order $order
* @return array
*/
function cs_add_order_again_to_my_orders_actions( $actions, $order ) {
if ( $order->has_status( 'completed' ) ) {
@claudiosanches
claudiosanches / custom-my-account-endpoint.php
Last active Nov 30, 2019
Example of custom My Account endpoint.
View custom-my-account-endpoint.php
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
@claudiosanches
claudiosanches / plugin.php
Created May 2, 2017
WooCommerce - Send "New User Registration" email to admins when new customer is created.
View plugin.php
<?php
/**
* Send "New User Registration" email to admins when new customer is created on WooCommerce.
*
* @param int $id New customer ID.
*/
function my_wc_customer_created_notification( $id ) {
wp_new_user_notification( $id, null, 'admin' );
}
View woocommerce-pay-button-sample.php
<?php
/**
* Plugin Name: Test "pay button" support
*/
add_action( 'plugins_loaded', function() {
class My_Custom_Gateway extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'custom_gateway';
$this->has_fields = false;
@claudiosanches
claudiosanches / php-mail.md
Last active Oct 31, 2019
Ubuntu - PHP email with Gmail.
View php-mail.md

Install

sudo apt-get install ssmtp

Configuration

Open /etc/ssmtp/ssmtp.conf.

@claudiosanches
claudiosanches / functions.php
Created May 24, 2014
WooCommerce Extra Checkout Fields for Brazil - Neighborhood required
View functions.php
<?php
function custom_wcbcf_billing_fields( $fields ) {
$fields['billing_neighborhood']['required'] = true;
return $fields;
}
add_filter( 'wcbcf_billing_fields', 'custom_wcbcf_billing_fields' );
function custom_wcbcf_shipping_fields( $fields ) {
You can’t perform that action at this time.