Sunday 19 June 2016

How to change Product page structure in WordPress, WooCommerce?

1> Create folder "woocommerce" in your theme.
2> your product page templte at following address:
   "/public_html/wp-content/plugins/woocommerce/templates"
3> download "content-single-product.php" file & put in theme "woocommerce" folder
4> "content-single-product.php" code Under standing below:
<?php
/**
* woocommerce_single_product_summary hook
*
* @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_rating - 10
* @hooked woocommerce_template_single_price - 10
* @hooked woocommerce_template_single_excerpt - 20
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
*/

do_action( 'woocommerce_single_product_summary' );
?>
Above code can be print product title,Price,short discription etc.
To change it go follwing path
"/public_html/wp-content/plugins/woocommerce/includes/wc-template-hooks.php" file.

You can see follwing code:
/**
* Product Summary Box.
*
* @see woocommerce_template_single_title()
* @see woocommerce_template_single_rating()
* @see woocommerce_template_single_price()
* @see woocommerce_template_single_excerpt()
* @see woocommerce_template_single_meta()
* @see woocommerce_template_single_sharing()
*/
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );

From here it comes output.

5> for remove any function copy following code in your "functions.php" file in your theme.
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );

Code for Product Title:-
<?php if( mfn_opts_get('shop-product-title') != 'sub' ): ?>
<center><h1 itemprop="name" class="product_title entry-title product_title"><?php the_title(); ?></h1></center>
<?php endif; ?>

Code for Short discription:-
<div itemprop="description" class="wooshortdiscription">
<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
</div>

Take code from "/public_html/wp-content/plugins/woocommerce/templates/single-product" files & put in Your "content-single-product.php" as you need.

6> Never change original file because when its update your modified code will be lost.


    
For more Interesting, Useful Article & codes visit IT New Code.

Ankit Shah PHP Expert

IT New Code suggest a solution for your problem related to coding, Specially .PHP, Wordpress, WooCommerce, Magento, HTML and CSS. Visit Our website for Information.

3 comments:

  1. Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well. The way of writing is excellent and also the content is top-notch. Thanks for that insight you provide the readers! Change site title and tagline in wordpress

    ReplyDelete
  2. Well, Really good job with the article. Over the last few years there has been a phenomenal growth in the eCommerce industry. A number of factors are held responsible for the same and one of the most important one is the use of WordPress plugin named WooCommerce. You can follow this URL: https://goo.gl/GikSN3 If you would love to read more about WooCommerce.

    ReplyDelete
  3. I really appereciate your work, its really good.

    Among the e-marketers, WooCommerce is becoming more and more popular with passing time. WooCommerce is nothing but, a WordPress plugin which is specifically designed for online stores. It helps the business owners and web masters to sell products online with ease. I’ve come across this article which helps the business people to go for it for their online store expansion. URL: https://goo.gl/pXKVeo You will love to read this.

    Thanks!

    ReplyDelete

 

Copyright @ 2016 IT New Code | Developing Code | Designing Code.

Designed by: Ankit Shah