Skip to content

Instantly share code, notes, and snippets.

article.post .post-content {
width: 100%;
}
.single article.post .post-content {
width: 96%;
}
aside.post-meta {
display: none !important;
add_filter( 'post_row_actions', 'remove_duplicate_capability', 20, 2 );
add_filter( 'page_row_actions', 'remove_duplicate_capability', 20, 2 );
function remove_duplicate_capability( $actions, $post ) {
if ( $post->post_type != 'product' ) {
return $actions;
}
if ( isset( $actions['duplicate'] ) ) {
unset( $actions['duplicate'] );
}
/**
* Sell only in California
*/
function wc_sell_only_states( $states ) {
$states['US'] = array(
'CA' => __( 'California', 'woocommerce' ),
'TX' => __( 'Texas', 'woocommerce' ),
);
return $states;
}
add_action( 'woocommerce_after_shop_loop_item_title', 'custom_print_stock', 9 );
function custom_print_stock() {
global $product;
printf( '<span>Available: %d</span>', esc_html( $product->get_stock_quantity() ) );
}
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
add_action( 'woocommerce_proceed_to_checkout', 'change_url_to_checkout', 20 );
function change_url_to_checkout() {
$cart = WC()->cart->get_cart();
$url = '';
foreach ( $cart as $item ) {
if ( $item['product_id'] === 70 ) {
$url = 'put_your_extra_page_url_here';
break;
add_action( 'init', 'remove_jpcf_nonadmin' );
function remove_jpcf_nonadmin() {
if ( ! current_user_can( 'manage_woocommerce' ) ) {
remove_action( 'media_buttons', 'grunion_media_button', 999 );
}
}
ul.products li.product .onsale {
position: absolute;
top: 200px;
right: 85px;
}
.onsale {
background-color: #FFFFFF;
border-color: #FF0000 !important;
color: #FF0000 !important;
}
/**
* Change the Shop archive page title.
* @param string $title
* @return string
*/
function wc_custom_shop_archive_title( $title ) {
if ( is_shop() && isset( $title['title'] ) ) {
$title['title'] = 'My Title';
}
add_action( 'woocommerce_order_status_completed', 'change_role_on_purchase' );
function change_role_on_purchase( $order_id ) {
$order = wc_get_order( $order_id );
$items = $order->get_items();
$products_to_check = array( '1', '2', '3' );
foreach ( $items as $item ) {
if ( $order->user_id > 0 && in_array( $item['product_id'], $products_to_check ) ) {
$role = 'new-role';