woocommerce

一、woocommerce获取产品基本信息

1、关于钩子定义

位置:根目录/wp-content/plugins/woocommerce/include/wc-template-hooks.php第144行开始

  1. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
  2. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
  3. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
  4. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
  5. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
  6. add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );

2、相关联的函数:

代码位置:根目录/wp-content/plugins/woocommerce/include/wc-template-functions.php第825行开始

  1. if ( ! function_exists( 'woocommerce_template_single_title' ) ) {
  2. /**
  3. * Output the product title.
  4. *
  5. * @subpackage Product
  6. */
  7. function woocommerce_template_single_title() {
  8. wc_get_template( 'single-product/title.php' );
  9. }
  10. }
  11. if ( ! function_exists( 'woocommerce_template_single_rating' ) ) {
  12. /**
  13. * Output the product rating.
  14. *
  15. * @subpackage Product
  16. */
  17. function woocommerce_template_single_rating() {
  18. wc_get_template( 'single-product/rating.php' );
  19. }
  20. }
  21. if ( ! function_exists( 'woocommerce_template_single_price' ) ) {
  22. /**
  23. * Output the product price.
  24. *
  25. * @subpackage Product
  26. */
  27. function woocommerce_template_single_price() {
  28. wc_get_template( 'single-product/price.php' );
  29. }
  30. }
  31. if ( ! function_exists( 'woocommerce_template_single_excerpt' ) ) {
  32. /**
  33. * Output the product short description (excerpt).
  34. *
  35. * @subpackage Product
  36. */
  37. function woocommerce_template_single_excerpt() {
  38. wc_get_template( 'single-product/short-description.php' );
  39. }
  40. }
  41. if ( ! function_exists( 'woocommerce_template_single_meta' ) ) {
  42. /**
  43. * Output the product meta.
  44. *
  45. * @subpackage Product
  46. */
  47. function woocommerce_template_single_meta() {
  48. wc_get_template( 'single-product/meta.php' );
  49. }
  50. }
  51. if ( ! function_exists( 'woocommerce_template_single_sharing' ) ) {
  52. /**
  53. * Output the product sharing.
  54. *
  55. * @subpackage Product
  56. */
  57. function woocommerce_template_single_sharing() {
  58. wc_get_template( 'single-product/share.php' );
  59. }
  60. }

3、相关模板输出:根据以上函数,很容易可以推断出模板的位置:

文件位置:根目录/wp-content/themes/当前模板/woocommerce/single-product/目录下可找到相应的模板

二、woocommerce修改购物车的样式(没有page页面的情况下)

主体内容的修改要在content.php里面修改