Skip to content

Instantly share code, notes, and snippets.

View ahmedeshaan's full-sized avatar

Ahmed Eshaan ahmedeshaan

View GitHub Profile
<?php
add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
$html .= '</form>';
}
<script>
jQuery(document).ready(function ($) {
function removeLoader() {
$('.product-type-external').find('.single_add_to_cart_button').removeClass('loading');
}
$('.product-type-external').find('.single_add_to_cart_button').attr("target", "_blank");
$('.product-type-external').find('.single_add_to_cart_button').on("click", removeLoader);
});
</script>
<script type="text/javascript">
jQuery(function($){
$('.menu-item.has-child').each(function(){
$(this).addClass('active');
});
});
add_action( 'woocommerce_add_order_item_meta', 'flatsome_add_sku_order_details', 10, 3 );
function flatsome_add_sku_order_details( $item_id, $values, $cart_item_key ) {
$item_sku = get_post_meta( $values[ 'product_id' ], '_sku', true );
wc_add_order_item_meta( $item_id, 'sku', $item_sku , false );
}
add_action('wp', function(){
remove_action( 'flatsome_category_title_alt', 'woocommerce_result_count', 20 );
remove_action( 'flatsome_category_title_alt', 'woocommerce_catalog_ordering', 30 );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
});
<?php
function remove_woocommerce_process_registration() {
remove_action('init', 'woocommerce_process_registration');
}
add_action('init','remove_woocommerce_process_registration');
add_action( 'init', 'my_process_registration' );
add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 );
function shorten_woo_product_title( $title, $id ) {
if ( is_shop() && get_post_type( $id ) === 'product' ) {
return substr( $title, 0, 15 ); // change last number to the number of characters you want
} else {
return $title;
}
}
[row]
[col span="6" span__sm="12"]
[ux_product_gallery]
[/col]
[col span="6" span__sm="12"]
/* iPhone 6 in portrait & landscape */
@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px) { /* STYLES GO HERE */}
/* iPhone 6 in landscape */
@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px)
and (orientation : landscape) { /* STYLES GO HERE */}
<?php
add_filter('gettext', 'translate_text');
add_filter('ngettext', 'translate_text');
function translate_text($translated) {