Skip to content

Instantly share code, notes, and snippets.

View chrdesigner's full-sized avatar

César Ribeiro chrdesigner

View GitHub Profile
@chrdesigner
chrdesigner / function.php
Last active August 29, 2015 14:06
WooCommerce - Additional Information tab
<?php
//Hide dimensions in Additional Information tab
add_filter( 'wc_product_enable_dimensions_display', '__return_false' );
//Hide Additional Information tab
function custom_woocommerce_product_tabs( $tabs ) {
if ( isset( $tabs['additional_information'] ) ) {
unset( $tabs['additional_information'] );
@chrdesigner
chrdesigner / function.php
Last active August 29, 2015 14:19
Custom sorting options - alphabet order - WooCommerce
<?php
// Custom sorting options
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' );
function custom_woocommerce_get_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ('title_asc' == $orderby_value) {
$args['orderby'] = 'title';
$args['order'] = 'ASC';
$args['meta_key'] = '';
@chrdesigner
chrdesigner / function.php
Last active August 29, 2015 14:19
Adding a hook callback - alphabet order - WooCommerce
<?php
// Adding a hook callback.
add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_woocommerce_catalog_orderby' );
add_filter( 'woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby' );
function custom_woocommerce_catalog_orderby( $sortby ) {
$sortby['title_asc'] = __('Alphabetical - (A - Z)', 'your-theme');
$sortby['title_desc'] = __('Alphabetical - (Z - A)', 'your-theme');
return $sortby;
}
@chrdesigner
chrdesigner / function.php
Created April 14, 2015 13:56
Remove Options - alphabet order - WooCommerce
<?php
// Remove Options
add_filter( 'woocommerce_catalog_orderby', 'custom_woocommerce_remove_filter' );
function custom_woocommerce_remove_filter( $catalog_orderby ) {
unset( $catalog_orderby['popularity'] );
unset( $catalog_orderby['rating'] );
unset( $catalog_orderby['price'] );
unset( $catalog_orderby['price-desc'] );
return $catalog_orderby;
}
@chrdesigner
chrdesigner / functions.php
Last active July 30, 2018 20:52
Vender Somente para Estado Específico - WooCommerce
<?php
/**
* Brazillian states
* Function - Vender Somente para Estados Específicos - WooCommerce
*/
function wc_especifico_estado( $states ) {
$states['BR'] = array(
'SP' => __( 'S&atilde;o Paulo', 'woocommerce' ),
'RJ' => __( 'Rio de Janeiro', 'woocommerce' ),
);
@chrdesigner
chrdesigner / functions.php
Created May 23, 2015 15:36
Adicionar Um Unico Item por Carrinho - WooCommerce
<?php
/*
* Função para adicionar um único item por carrinho
*/
function woo_unico_produto( $cart_item_data ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
return $cart_item_data;
}
@chrdesigner
chrdesigner / functions.php
Last active August 29, 2015 14:22
Add symbol United Arab Emirates Dirham
<?php
// Add symbol United Arab Emirates Dirham
add_filter( 'woocommerce_currencies', 'add_custom_currency' );
function add_custom_currency( $currencies ) {
$currencies['AED'] = __( 'United Arab Emirates Dirham', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_custom_currency_symbol', 10, 2);
function add_custom_currency_symbol( $currency_symbol, $currency ) {
@chrdesigner
chrdesigner / functions.php
Last active August 29, 2015 14:22
allow AED for WooCommerce
<?php
// allow AED for WooCommerce
add_filter( 'woocommerce_paypal_supported_currencies', 'paypal_aed_current' );
function paypal_aed_current($currency_array) {
$currency_array[] = 'AED';
return $currency_array;
}
@chrdesigner
chrdesigner / functions.php
Created June 17, 2015 14:14
Custom single post format template
<?php
/**
* Custom single post format template
* Reference: https://codex.wordpress.org/Function_Reference/get_post_format
*/
function chr_custom_single_post_format( $template ) {
if ( is_single() && has_post_format() ) {
$post_format_template = locate_template( 'single-' . get_post_format() . '.php' );
if ( $post_format_template ) {
$template = $post_format_template;
@chrdesigner
chrdesigner / main.js
Created July 20, 2015 12:26
Vertical Align with jQuery
$(function() {
$('.classVerticalAlign').css({
'position' : 'absolute',
'left' : '50%',
'top' : '50%',
'margin-left' : -$('.classVerticalAlign').outerWidth()/2,
'margin-top' : -$('.classVerticalAlign').outerHeight()/2
});
});