Skip to content

Instantly share code, notes, and snippets.

View ibndawood's full-sized avatar
💭
I may be slow to respond.

Kader Ibrahim S ibndawood

💭
I may be slow to respond.
View GitHub Profile
@ibndawood
ibndawood / functions.php
Last active August 29, 2015 14:14
Add to Cart button for Catalog Mode : MediaCenter Wordpress Theme
function catalog_mode_add_to_cart_link( $link, $product ){
global $media_center_theme_options, $woocommerce_loop;
$product_item_size = isset( $woocommerce_loop['product_item_size'] ) ? $woocommerce_loop['product_item_size'] : $media_center_theme_options['product_item_size'];
$btn_classes = 'le-button';
$btn_classes .= ( $product_item_size == 'size-big' ) ? 'big' : '';
if ( ( isset( $media_center_theme_options['catalog_mode'] ) ) && ( $media_center_theme_options['catalog_mode'] == 1 ) ) {
$link = '<div class="add-cart-button"><a href="'. $product->get_permalink() . '" rel="nofollow" class="' . $btn_classes . '">View Product</a></div>';
@ibndawood
ibndawood / functions.php
Created April 7, 2015 04:47
Show price only to Registered Users
add_filter( 'woocommerce_get_price_html', 'show_price_only_to_registered_users', PHP_INT_MAX );
function show_price_only_to_registered_users( $price ) {
if( ! is_user_logged_in() ){
return __( 'Please register to view prices', 'theme_name' );
} else {
return $price;
}
}
@ibndawood
ibndawood / functions.php
Created May 15, 2015 07:12
Changing "Shop By Department" in MediaCenter Wordpress Theme
add_filter( 'mc_shop_by_department', 'mc_change_shop_by_department', PHP_INT_MAX );
function mc_change_shop_by_department(){
return 'Shop Categories'; // Your custom text here
}
@ibndawood
ibndawood / style.css
Created May 19, 2015 06:44
MediaCenter WP: Changing the color of product title
.product-title > a, .product-title > a:hover, .product-title > a:focus, .product-title > a:active{
color: #00FF00;
}
@ibndawood
ibndawood / functions.php
Last active September 9, 2015 13:54
Displaying Stock availability like product labels
add_action( 'woocommerce_before_shop_loop_item_title', 'mc_make_availability_like_ribbon', 25 );
function mc_make_availability_like_ribbon() {
global $product;
$availability = $product->get_availability();
$stock_status = $availability['class'];
if( $stock_status == 'out-of-stock' ) {
$label = __( 'Out of Stock', 'mediacenter' ) ;
@ibndawood
ibndawood / functions.php
Created September 17, 2015 12:49
Removing Out of Stock items in Live Search
function woocommerce_products_live_search(){
if ( isset( $_REQUEST['fn'] ) && 'get_ajax_search' == $_REQUEST['fn'] ) {
$query_args = array(
'posts_per_page' => 10,
'no_found_rows' => true,
'post_type' => 'product',
);
if( isset( $_REQUEST['terms'] ) ) {
@ibndawood
ibndawood / functions.php
Created September 22, 2015 14:59
Change "See the Archive" text
<?php
add_filter( 'blog_archive_link_text', 'beth_child_change_archive_link_text' );
function beth_child_change_archive_link_text( $text ) {
return __( 'Your Text', 'bethlehem' );
}
@ibndawood
ibndawood / functions.php
Last active September 23, 2015 03:35
Overriding bethlehem navigation links
<?php
function bethlehem_navigation_links() {
$header = bethlehem_get_header();
?>
<div class="top-nav-links">
<?php if( $header == 'header-7' ) : ?>
<ul>
<li class="events-link">
<a href="<?php echo esc_url( tribe_get_events_link() ); ?>"><i class="fa fa-calendar"></i><?php echo __( 'Calendar', 'bethlehem' ); ?></a>
</li>
@ibndawood
ibndawood / scripts.js
Created September 29, 2015 16:29
Prevent scrolling to top
$('body').on('added_to_cart', function(){
$('.product-item').unblock(); // Unblock the product item
$('.cart-item').unblock();
$('.compare-list').unblock();
$('html,body').animate({
scrollTop: $('.top-cart-holder').offset().top - 20
}, 1000, function(){
$('.top-cart-holder .dropdown-toggle').dropdown('toggle');
@ibndawood
ibndawood / functions.php
Created September 30, 2015 15:02
Shop By Departments menu
<?php
function media_center_department_nav_menu(){
$department_nav_menu = '';
$department_nav_menu .= '<ul class="dropdown-menu">';
$department_nav_menu .= wp_list_categories(
array(
'title_li' => '',
'hide_empty' => 1 ,
'taxonomy' => 'product_cat',