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
//Copy flatsome theme file to child theme and add below code code to it.
themes/flatsome/woocommerce/cart/cart.php
Search this line <div class="col large-7 pb-0 <?php echo $main_classes; ?>">
and replace it with <div class="col large-12 pb-0 <?php echo $main_classes; ?>">
Search this line <div class="cart-collaterals large-5 col pb-0">
add replace it with below code
<div class="cart-collaterals large-7 col pb-0"><h2>My Custom stuff will be there</h2></div>
<?php
//reorder flatsome checkout page email field
function ci_woo_reorder_fields($fields) {
$fields['billing']['billing_email']['priority'] = 20;
return $fields;
}
add_filter('woocommerce_checkout_fields','ci_woo_reorder_fields');
<?php
//flatsome theme display role after account user
function display_role_after_account_user() {
$user_id = get_current_user_id();
$user_meta=get_userdata($user_id);
$user_roles=$user_meta->roles[0];
<?php
//flatsome theme customize accounts area
function add_flatsome_account_links() {
$label = "My Test Link";
$endpoint = "test-endpoint";
?>
<li class="<?php echo wc_get_account_menu_item_classes( $endpoint ); ?>">
<a style="color: red" href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"><?php echo esc_html( $label ); ?></a>
<?php
/*
Flatsome Theme Product On-Sale End Counter
*/
function display_onsale_product_counter() {
global $product;
if ( $product->is_on_sale() )
/*
flatsome [ux-countdown] shortcode usage
*/
//Admin side shortcode
[ux_countdown year="2019" month="10" day="30" time="15:00"]
//Add below in functions.php
echo do_shortcode('[ux_countdown year="2019" month="10" day="30" time="15:00"]');
<?php
woocommerce_wp_text_input(
array(
'id' => '_text_field',
'label' => __( 'Text Field', 'woocommerce' ),
'placeholder' => '',
'desc_tip' => 'true',
'description' => __( 'Enter text here.', 'woocommerce' )
)
<?php
// Display product Fields
add_action( 'woocommerce_product_options_general_product_data', 'ci_custom_general_tab_fields' );
function ci_custom_general_tab_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
<?php
// Save All Fields
add_action( 'woocommerce_process_product_meta', 'ci_custom_general_tab_fields_save' );
//Saving Fields Values
function ci_custom_general_tab_fields_save( $post_id ){
// Text Field
$woocommerce_text_field = $_POST['_text_field'];
if( !empty( $woocommerce_text_field ) )
<?php
//Display custom fields on Woocommerce Product Details Page
add_action( 'woocommerce_single_product_summary', 'ci_woo_product_detail', 5 );
function ci_woo_product_detail() {
global $product;
echo '<div>';
echo '<span><strong> Text Field:</strong> ' . get_post_meta( $product->id, '_text_field', true ) . '</span>';