Skip to content

Instantly share code, notes, and snippets.

View imran-khan1's full-sized avatar

Imran Khan imran-khan1

  • WordPress Developer
  • Pakistan
View GitHub Profile
<?php
/*
* Reorder WooCommerce Checkout Fields
*/
function ci_woo_reorder_fields($fields) {
$fields['billing']['billing_first_name']['priority'] = 10;
$fields['billing']['billing_last_name']['priority'] = 20;
$fields['billing']['billing_email']['priority'] = 30;
$fields['billing']['billing_phone']['priority'] = 40;
<?php
/*
* Remove some checkout billing fields
*/
function ci_woo_billing_fields($fields){
unset( $fields["billing_country"] );
unset( $fields["billing_company"] );
unset( $fields["billing_address_1"] );
unset( $fields["billing_address_2"] );
<?php
/*
*remove Order Notes from checkout field in Woocommerce
*/
add_filter( 'woocommerce_checkout_fields' , 'ci_woo_checkout_fields' );
function ci_woo_checkout_fields( $fields ) {
unset($fields['order']['order_comments']);
return $fields;
}
<?php
/*
* remove checkout field in Woocommerce
*/
add_filter( 'woocommerce_checkout_fields' , 'ci_woo_checkout_fields' );
function ci_woo_checkout_fields( $fields ) {
unset($fields['billing']['billing_first_name']); // remove the customer's First Name for billing
<?php
//remove flatsome woocommerce shop page product category
remove_action('woocommerce_shop_loop_item_title','flatsome_woocommerce_shop_loop_category', 0);
<?php
//flatsome on_sale product custom text
function display_text_product_box_after() {
global $product;
if ( $product->is_on_sale() )
{
echo '<b style="color:red">Limited time offer</b>';
}
<?php
//flatsome display text after product detail page image, if product is on sale
function display_flatsome_after_product_images() {
global $product;
if ( $product->is_on_sale() )
{
echo '<div style="color:red; border:1px solid #ccc;">Limited time offer</div>';
}
<?php
//flatsome product detail page text after excerpt
function display_after_short_description($excerpt) {
$add_to_excerpt = $excerpt . "<p style='color:green'>Add anything after excerpt</p>";
return $add_to_excerpt;
}
<?php
// display text after flatsome cart sidebar
function display_text_after_flatsome_cart_sidebar()
{
echo '<b style="color:red; font-size:20px;">Limited time offer</b>';
}
add_action('flatsome_cart_sidebar', 'display_text_after_flatsome_cart_sidebar');
<?php
//display data in cart item table
function display_data_in_cart_item_table( $product_name, $cart_item, $cart_item_key ) {
$categories = wc_get_product_category_list( $cart_item['product_id']);
$product_sku = get_post_meta($cart_item['product_id'] , '_sku', true);
$product_name = $product_name . '<dl style="border:2px solid red;padding:10px;">
<dt>Category : </dt>