Skip to content

Instantly share code, notes, and snippets.

César Ribeiro chrdesigner

Block or report user

Report or block chrdesigner

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
View archive-product.php
<?php
/*
* WP_Query - Show in your result search page, How many, products were found.
*/
$mySearch =& new WP_Query("s=$s & showposts=-1"); $num = $mySearch->post_count; ?>
<h1 class="page-title search-products-alert">
Foram encontrados <strong><?php echo $num;?></strong> resultados para a busca: <strong><?php echo get_search_query(); ?></strong>
</h1>
@chrdesigner
chrdesigner / functions.php
Last active Aug 25, 2015
Function - Remove Loop/Single Button Add to Cart
View functions.php
<?php
/*
* Function - Remove Loop/Single Button Add to Cart
*/
add_action('init','remove_add_to_cart');
function remove_add_to_cart(){
if(is_user_logged_in()){}else{
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
@chrdesigner
chrdesigner / functions.php
Last active Aug 25, 2015
Function - Show the price only after logging
View functions.php
<?php
/*
* Function - Show the price only after logging
*/
add_filter('woocommerce_get_price_html','show_price_logged');
function show_price_logged($price){
if( is_user_logged_in() ){
return $price;
} else {
return '<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '" title="Já tenho Conta" class="btn-myaccount">Já tenho Conta</a> ou <a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '" title="Registrar para visualizar o preço!" class="btn-registrar">Registrar para visualizar o preço!</a>';
View functions.php
<?php
// Remove o Field de Informação adicional
add_filter( 'woocommerce_checkout_fields' , 'alter_woocommerce_checkout_fields' );
function alter_woocommerce_checkout_fields( $fields ) {
unset($fields['order']['order_comments']);
return $fields;
}
// Remove o título de Informação adicional
add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
@chrdesigner
chrdesigner / function.php
Last active Aug 29, 2015
add rel prettyphoto to all images
View function.php
<?php
/* add rel prettyphoto to all images */
function autoadd_rel_prettyPhoto($content) {
global $post;
$pattern = "/(<a(?![^>]*?data-rel=['\"]prettyPhoto.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)['\"][^\>]*)>/i";
$replacement = '$1 data-rel="prettyPhoto['.$post->ID.']">';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter("the_content","autoadd_rel_prettyPhoto");
@chrdesigner
chrdesigner / function.php
Last active Aug 29, 2015
WooCommerce - Additional Information tab
View function.php
<?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 Aug 29, 2015
Custom sorting options - alphabet order - WooCommerce
View function.php
<?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 Aug 29, 2015
Adding a hook callback - alphabet order - WooCommerce
View function.php
<?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 / functions.php
Created May 23, 2015
Adicionar Um Unico Item por Carrinho - WooCommerce
View functions.php
<?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 Aug 29, 2015
Add symbol United Arab Emirates Dirham
View functions.php
<?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 ) {
You can’t perform that action at this time.