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
/*
Flatsome Theme Product On-Sale End Counter
*/
function display_onsale_product_counter() {
global $product;
if ( $product->is_on_sale() )
<?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 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
//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');
//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
//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>
<?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
//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
//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 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>';
}