WC_Abstract_Legacy_Product

Legacy Abstract Product.

Defined (1)

The class is defined in the following location(s).

/includes/legacy/abstract-wc-legacy-product.php  
  1. abstract class WC_Abstract_Legacy_Product extends WC_Data { 
  2.  
  3. /** 
  4. * Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past. 
  5. * @param string $key Key name. 
  6. * @return bool 
  7. */ 
  8. public function __isset( $key ) { 
  9. $valid = array( 
  10. 'id',  
  11. 'product_attributes',  
  12. 'visibility',  
  13. 'sale_price_dates_from',  
  14. 'sale_price_dates_to',  
  15. 'post',  
  16. 'download_type',  
  17. 'product_image_gallery',  
  18. 'variation_shipping_class',  
  19. 'shipping_class',  
  20. 'total_stock',  
  21. 'crosssell_ids',  
  22. 'parent',  
  23. ); 
  24. if ( $this->is_type( 'variation' ) ) { 
  25. $valid = array_merge( $valid, array( 
  26. 'variation_id',  
  27. 'variation_data',  
  28. 'variation_has_stock',  
  29. 'variation_shipping_class_id',  
  30. 'variation_has_sku',  
  31. 'variation_has_length',  
  32. 'variation_has_width',  
  33. 'variation_has_height',  
  34. 'variation_has_weight',  
  35. 'variation_has_tax_class',  
  36. 'variation_has_downloadable_files',  
  37. ) ); 
  38. return in_array( $key, array_merge( $valid, array_keys( $this->data ) ) ) || metadata_exists( 'post', $this->get_id(), '_' . $key ) || metadata_exists( 'post', $this->get_parent_id(), '_' . $key ); 
  39.  
  40. /** 
  41. * Magic __get method for backwards compatibility. Maps legacy vars to new getters. 
  42. * @param string $key Key name. 
  43. * @return mixed 
  44. */ 
  45. public function __get( $key ) { 
  46.  
  47. if ( 'post_type' === $key ) { 
  48. return $this->post_type; 
  49.  
  50. wc_doing_it_wrong( $key, __( 'Product properties should not be accessed directly.', 'woocommerce' ), '3.0' ); 
  51.  
  52. switch ( $key ) { 
  53. case 'id' : 
  54. $value = $this->is_type( 'variation' ) ? $this->get_parent_id() : $this->get_id(); 
  55. break; 
  56. case 'product_type' : 
  57. $value = $this->get_type(); 
  58. break; 
  59. case 'product_attributes' : 
  60. $value = isset( $this->data['attributes'] ) ? $this->data['attributes'] : ''; 
  61. break; 
  62. case 'visibility' : 
  63. $value = $this->get_catalog_visibility(); 
  64. break; 
  65. case 'sale_price_dates_from' : 
  66. return $this->get_date_on_sale_from() ? $this->get_date_on_sale_from()->getTimestamp() : ''; 
  67. break; 
  68. case 'sale_price_dates_to' : 
  69. return $this->get_date_on_sale_to() ? $this->get_date_on_sale_to()->getTimestamp() : ''; 
  70. break; 
  71. case 'post' : 
  72. $value = get_post( $this->get_id() ); 
  73. break; 
  74. case 'download_type' : 
  75. return 'standard'; 
  76. break; 
  77. case 'product_image_gallery' : 
  78. $value = $this->get_gallery_image_ids(); 
  79. break; 
  80. case 'variation_shipping_class' : 
  81. case 'shipping_class' : 
  82. $value = $this->get_shipping_class(); 
  83. break; 
  84. case 'total_stock' : 
  85. $value = $this->get_total_stock(); 
  86. break; 
  87. case 'downloadable' : 
  88. case 'virtual' : 
  89. case 'manage_stock' : 
  90. case 'featured' : 
  91. case 'sold_individually' : 
  92. $value = $this->{"get_$key"}() ? 'yes' : 'no'; 
  93. break; 
  94. case 'crosssell_ids' : 
  95. $value = $this->get_cross_sell_ids(); 
  96. break; 
  97. case 'upsell_ids' : 
  98. $value = $this->get_upsell_ids(); 
  99. break; 
  100. case 'parent' : 
  101. $value = wc_get_product( $this->get_parent_id() ); 
  102. break; 
  103. case 'variation_id' : 
  104. $value = $this->is_type( 'variation' ) ? $this->get_id() : ''; 
  105. break; 
  106. case 'variation_data' : 
  107. $value = $this->is_type( 'variation' ) ? wc_get_product_variation_attributes( $this->get_id() ) : ''; 
  108. break; 
  109. case 'variation_has_stock' : 
  110. $value = $this->is_type( 'variation' ) ? $this->managing_stock() : ''; 
  111. break; 
  112. case 'variation_shipping_class_id' : 
  113. $value = $this->is_type( 'variation' ) ? $this->get_shipping_class_id() : ''; 
  114. break; 
  115. case 'variation_has_sku' : 
  116. case 'variation_has_length' : 
  117. case 'variation_has_width' : 
  118. case 'variation_has_height' : 
  119. case 'variation_has_weight' : 
  120. case 'variation_has_tax_class' : 
  121. case 'variation_has_downloadable_files' : 
  122. $value = true; // These were deprecated in 2.2 and simply returned true in 2.6.x. 
  123. break; 
  124. default : 
  125. if ( in_array( $key, array_keys( $this->data ) ) ) { 
  126. $value = $this->{"get_$key"}(); 
  127. } else { 
  128. $value = get_post_meta( $this->id, '_' . $key, true ); 
  129. break; 
  130. return $value; 
  131.  
  132. /** 
  133. * If set, get the default attributes for a variable product. 
  134. * @deprecated 3.0.0 
  135. * @return array 
  136. */ 
  137. public function get_variation_default_attributes() { 
  138. wc_deprecated_function( 'WC_Product_Variable::get_variation_default_attributes', '3.0', 'WC_Product::get_default_attributes' ); 
  139. return apply_filters( 'woocommerce_product_default_attributes', $this->get_default_attributes(), $this ); 
  140.  
  141. /** 
  142. * Returns the gallery attachment ids. 
  143. * @deprecated 3.0.0 
  144. * @return array 
  145. */ 
  146. public function get_gallery_attachment_ids() { 
  147. wc_deprecated_function( 'WC_Product::get_gallery_attachment_ids', '3.0', 'WC_Product::get_gallery_image_ids' ); 
  148. return $this->get_gallery_image_ids(); 
  149.  
  150. /** 
  151. * Set stock level of the product. 
  152. * @deprecated 3.0.0 
  153. */ 
  154. public function set_stock( $amount = null, $mode = 'set' ) { 
  155. wc_deprecated_function( 'WC_Product::set_stock', '3.0', 'wc_update_product_stock' ); 
  156. return wc_update_product_stock( $this, $amount, $mode ); 
  157.  
  158. /** 
  159. * Reduce stock level of the product. 
  160. * @deprecated 3.0.0 
  161. * @param int $amount Amount to reduce by. Default: 1 
  162. * @return int new stock level 
  163. */ 
  164. public function reduce_stock( $amount = 1 ) { 
  165. wc_deprecated_function( 'WC_Product::reduce_stock', '3.0', 'wc_update_product_stock' ); 
  166. return wc_update_product_stock( $this, $amount, 'decrease' ); 
  167.  
  168. /** 
  169. * Increase stock level of the product. 
  170. * @deprecated 3.0.0 
  171. * @param int $amount Amount to increase by. Default 1. 
  172. * @return int new stock level 
  173. */ 
  174. public function increase_stock( $amount = 1 ) { 
  175. wc_deprecated_function( 'WC_Product::increase_stock', '3.0', 'wc_update_product_stock' ); 
  176. return wc_update_product_stock( $this, $amount, 'increase' ); 
  177.  
  178. /** 
  179. * Check if the stock status needs changing. 
  180. * @deprecated 3.0.0 Sync is done automatically on read/save, so calling this should not be needed any more. 
  181. */ 
  182. public function check_stock_status() { 
  183. wc_deprecated_function( 'WC_Product::check_stock_status', '3.0' ); 
  184.  
  185. /** 
  186. * Get and return related products. 
  187. * @deprecated 3.0.0 Use wc_get_related_products instead. 
  188. */ 
  189. public function get_related( $limit = 5 ) { 
  190. wc_deprecated_function( 'WC_Product::get_related', '3.0', 'wc_get_related_products' ); 
  191. return wc_get_related_products( $this->get_id(), $limit ); 
  192.  
  193. /** 
  194. * Retrieves related product terms. 
  195. * @deprecated 3.0.0 Use wc_get_product_term_ids instead. 
  196. */ 
  197. protected function get_related_terms( $term ) { 
  198. wc_deprecated_function( 'WC_Product::get_related_terms', '3.0', 'wc_get_product_term_ids' ); 
  199. return array_merge( array( 0 ), wc_get_product_term_ids( $this->get_id(), $term ) ); 
  200.  
  201. /** 
  202. * Builds the related posts query. 
  203. * @deprecated 3.0.0 Use Product Data Store get_related_products_query instead. 
  204. */ 
  205. protected function build_related_query( $cats_array, $tags_array, $exclude_ids, $limit ) { 
  206. wc_deprecated_function( 'WC_Product::build_related_query', '3.0', 'Product Data Store get_related_products_query' ); 
  207. $data_store = WC_Data_Store::load( 'product' ); 
  208. return $data_store->get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit ); 
  209.  
  210. /** 
  211. * Returns the child product. 
  212. * @deprecated 3.0.0 Use wc_get_product instead. 
  213. * @param mixed $child_id 
  214. * @return WC_Product|WC_Product|WC_Product_variation 
  215. */ 
  216. public function get_child( $child_id ) { 
  217. wc_deprecated_function( 'WC_Product::get_child', '3.0', 'wc_get_product' ); 
  218. return wc_get_product( $child_id ); 
  219.  
  220. /** 
  221. * Functions for getting parts of a price, in html, used by get_price_html. 
  222. * @deprecated 3.0.0 
  223. * @return string 
  224. */ 
  225. public function get_price_html_from_text() { 
  226. wc_deprecated_function( 'WC_Product::get_price_html_from_text', '3.0', 'wc_get_price_html_from_text' ); 
  227. return wc_get_price_html_from_text(); 
  228.  
  229. /** 
  230. * Functions for getting parts of a price, in html, used by get_price_html. 
  231. * @deprecated 3.0.0 Use wc_format_sale_price instead. 
  232. * @param string $from String or float to wrap with 'from' text 
  233. * @param mixed $to String or float to wrap with 'to' text 
  234. * @return string 
  235. */ 
  236. public function get_price_html_from_to( $from, $to ) { 
  237. wc_deprecated_function( 'WC_Product::get_price_html_from_to', '3.0', 'wc_format_sale_price' ); 
  238. return apply_filters( 'woocommerce_get_price_html_from_to', wc_format_sale_price( $from, $to ), $from, $to, $this ); 
  239.  
  240. /** 
  241. * Lists a table of attributes for the product page. 
  242. * @deprecated 3.0.0 Use wc_display_product_attributes instead. 
  243. */ 
  244. public function list_attributes() { 
  245. wc_deprecated_function( 'WC_Product::list_attributes', '3.0', 'wc_display_product_attributes' ); 
  246. wc_display_product_attributes( $this ); 
  247.  
  248. /** 
  249. * Returns the price (including tax). Uses customer tax rates. Can work for a specific $qty for more accurate taxes. 
  250. * @deprecated 3.0.0 Use wc_get_price_including_tax instead. 
  251. * @param int $qty 
  252. * @param string $price to calculate, left blank to just use get_price() 
  253. * @return string 
  254. */ 
  255. public function get_price_including_tax( $qty = 1, $price = '' ) { 
  256. wc_deprecated_function( 'WC_Product::get_price_including_tax', '3.0', 'wc_get_price_including_tax' ); 
  257. return wc_get_price_including_tax( $this, array( 'qty' => $qty, 'price' => $price ) ); 
  258.  
  259. /** 
  260. * Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting. 
  261. * @deprecated 3.0.0 Use wc_get_price_to_display instead. 
  262. * @param string $price to calculate, left blank to just use get_price() 
  263. * @param integer $qty passed on to get_price_including_tax() or get_price_excluding_tax() 
  264. * @return string 
  265. */ 
  266. public function get_display_price( $price = '', $qty = 1 ) { 
  267. wc_deprecated_function( 'WC_Product::get_display_price', '3.0', 'wc_get_price_to_display' ); 
  268. return wc_get_price_to_display( $this, array( 'qty' => $qty, 'price' => $price ) ); 
  269.  
  270. /** 
  271. * Returns the price (excluding tax) - ignores tax_class filters since the price may *include* tax and thus needs subtracting. 
  272. * Uses store base tax rates. Can work for a specific $qty for more accurate taxes. 
  273. * @deprecated 3.0.0 Use wc_get_price_excluding_tax instead. 
  274. * @param int $qty 
  275. * @param string $price to calculate, left blank to just use get_price() 
  276. * @return string 
  277. */ 
  278. public function get_price_excluding_tax( $qty = 1, $price = '' ) { 
  279. wc_deprecated_function( 'WC_Product::get_price_excluding_tax', '3.0', 'wc_get_price_excluding_tax' ); 
  280. return wc_get_price_excluding_tax( $this, array( 'qty' => $qty, 'price' => $price ) ); 
  281.  
  282. /** 
  283. * Adjust a products price dynamically. 
  284. * @deprecated 3.0.0 
  285. * @param mixed $price 
  286. */ 
  287. public function adjust_price( $price ) { 
  288. wc_deprecated_function( 'WC_Product::adjust_price', '3.0', 'WC_Product::set_price / WC_Product::get_price' ); 
  289. $this->data['price'] = $this->data['price'] + $price; 
  290.  
  291. /** 
  292. * Returns the product categories. 
  293. * @deprecated 3.0.0 
  294. * @param string $sep (default: ', '). 
  295. * @param string $before (default: ''). 
  296. * @param string $after (default: ''). 
  297. * @return string 
  298. */ 
  299. public function get_categories( $sep = ', ', $before = '', $after = '' ) { 
  300. wc_deprecated_function( 'WC_Product::get_categories', '3.0', 'wc_get_product_category_list' ); 
  301. return wc_get_product_category_list( $this->get_id(), $sep, $before, $after ); 
  302.  
  303. /** 
  304. * Returns the product tags. 
  305. * @deprecated 3.0.0 
  306. * @param string $sep (default: ', '). 
  307. * @param string $before (default: ''). 
  308. * @param string $after (default: ''). 
  309. * @return array 
  310. */ 
  311. public function get_tags( $sep = ', ', $before = '', $after = '' ) { 
  312. wc_deprecated_function( 'WC_Product::get_tags', '3.0', 'wc_get_product_tag_list' ); 
  313. return wc_get_product_tag_list( $this->get_id(), $sep, $before, $after ); 
  314.  
  315. /** 
  316. * Get the product's post data. 
  317. * @deprecated 3.0.0 
  318. * @return WP_Post 
  319. */ 
  320. public function get_post_data() { 
  321. wc_deprecated_function( 'WC_Product::get_post_data', '3.0', 'get_post' ); 
  322.  
  323. // In order to keep backwards compatibility it's required to use the parent data for variations. 
  324. if ( $this->is_type( 'variation' ) ) { 
  325. $post_data = get_post( $this->get_parent_id() ); 
  326. } else { 
  327. $post_data = get_post( $this->get_id() ); 
  328.  
  329. return $post_data; 
  330.  
  331. /** 
  332. * Get the parent of the post. 
  333. * @deprecated 3.0.0 
  334. * @return int 
  335. */ 
  336. public function get_parent() { 
  337. wc_deprecated_function( 'WC_Product::get_parent', '3.0', 'WC_Product::get_parent_id' ); 
  338. return apply_filters( 'woocommerce_product_parent', absint( $this->get_post_data()->post_parent ), $this ); 
  339.  
  340. /** 
  341. * Returns the upsell product ids. 
  342. * @deprecated 3.0.0 
  343. * @return array 
  344. */ 
  345. public function get_upsells() { 
  346. wc_deprecated_function( 'WC_Product::get_upsells', '3.0', 'WC_Product::get_upsell_ids' ); 
  347. return apply_filters( 'woocommerce_product_upsell_ids', $this->get_upsell_ids(), $this ); 
  348.  
  349. /** 
  350. * Returns the cross sell product ids. 
  351. * @deprecated 3.0.0 
  352. * @return array 
  353. */ 
  354. public function get_cross_sells() { 
  355. wc_deprecated_function( 'WC_Product::get_cross_sells', '3.0', 'WC_Product::get_cross_sell_ids' ); 
  356. return apply_filters( 'woocommerce_product_crosssell_ids', $this->get_cross_sell_ids(), $this ); 
  357.  
  358. /** 
  359. * Check if variable product has default attributes set. 
  360. * @deprecated 3.0.0 
  361. * @return bool 
  362. */ 
  363. public function has_default_attributes() { 
  364. wc_deprecated_function( 'WC_Product_Variable::has_default_attributes', '3.0', 'a check against WC_Product::get_default_attributes directly' ); 
  365. if ( ! $this->get_default_attributes() ) { 
  366. return true; 
  367. return false; 
  368.  
  369. /** 
  370. * Get variation ID. 
  371. * @deprecated 3.0.0 
  372. * @return int 
  373. */ 
  374. public function get_variation_id() { 
  375. wc_deprecated_function( 'WC_Product::get_variation_id', '3.0', 'WC_Product::get_id(). It will always be the variation ID if this is a variation.' ); 
  376. return $this->get_id(); 
  377.  
  378. /** 
  379. * Get product variation description. 
  380. * @deprecated 3.0.0 
  381. * @return string 
  382. */ 
  383. public function get_variation_description() { 
  384. wc_deprecated_function( 'WC_Product::get_variation_description', '3.0', 'WC_Product::get_description()' ); 
  385. return $this->get_description(); 
  386.  
  387. /** 
  388. * Check if all variation's attributes are set. 
  389. * @deprecated 3.0.0 
  390. * @return boolean 
  391. */ 
  392. public function has_all_attributes_set() { 
  393. wc_deprecated_function( 'WC_Product::has_all_attributes_set', '3.0', 'an array filter on get_variation_attributes for a quick solution.' ); 
  394. $set = true; 
  395.  
  396. // undefined attributes have null strings as array values 
  397. foreach ( $this->get_variation_attributes() as $att ) { 
  398. if ( ! $att ) { 
  399. $set = false; 
  400. break; 
  401. return $set; 
  402.  
  403. /** 
  404. * Returns whether or not the variations parent is visible. 
  405. * @deprecated 3.0.0 
  406. * @return bool 
  407. */ 
  408. public function parent_is_visible() { 
  409. wc_deprecated_function( 'WC_Product::parent_is_visible', '3.0' ); 
  410. return $this->is_visible(); 
  411.  
  412. /** 
  413. * Get total stock - This is the stock of parent and children combined. 
  414. * @deprecated 3.0.0 
  415. * @return int 
  416. */ 
  417. public function get_total_stock() { 
  418. wc_deprecated_function( 'WC_Product::get_total_stock', '3.0', 'get_stock_quantity on each child. Beware of performance issues in doing so.' ); 
  419. if ( sizeof( $this->get_children() ) > 0 ) { 
  420. $total_stock = max( 0, $this->get_stock_quantity() ); 
  421.  
  422. foreach ( $this->get_children() as $child_id ) { 
  423. if ( 'yes' === get_post_meta( $child_id, '_manage_stock', true ) ) { 
  424. $stock = get_post_meta( $child_id, '_stock', true ); 
  425. $total_stock += max( 0, wc_stock_amount( $stock ) ); 
  426. } else { 
  427. $total_stock = $this->get_stock_quantity(); 
  428. return wc_stock_amount( $total_stock ); 
  429.  
  430. /** 
  431. * Get formatted variation data with WC < 2.4 back compat and proper formatting of text-based attribute names. 
  432. * @deprecated 3.0.0 
  433. * @return string 
  434. */ 
  435. public function get_formatted_variation_attributes( $flat = false ) { 
  436. wc_deprecated_function( 'WC_Product::get_formatted_variation_attributes', '3.0', 'wc_get_formatted_variation' ); 
  437. return wc_get_formatted_variation( $this, $flat ); 
  438.  
  439. /** 
  440. * Sync variable product prices with the children lowest/highest prices. 
  441. * @deprecated 3.0.0 not used in core. 
  442. */ 
  443. public function variable_product_sync( $product_id = '' ) { 
  444. wc_deprecated_function( 'WC_Product::variable_product_sync', '3.0' ); 
  445. if ( empty( $product_id ) ) { 
  446. $product_id = $this->get_id(); 
  447.  
  448. // Sync prices with children 
  449. if ( is_callable( array( __CLASS__, 'sync' ) ) ) { 
  450. self::sync( $product_id ); 
  451.  
  452. /** 
  453. * Sync the variable product's attributes with the variations. 
  454. */ 
  455. public static function sync_attributes( $product, $children = false ) { 
  456. if ( ! is_a( $product, 'WC_Product' ) ) { 
  457. $product = wc_get_product( $product ); 
  458.  
  459. /** 
  460. * Pre 2.4 handling where 'slugs' were saved instead of the full text attribute. 
  461. * Attempt to get full version of the text attribute from the parent and UPDATE meta. 
  462. */ 
  463. if ( version_compare( get_post_meta( $product->get_id(), '_product_version', true ), '2.4.0', '<' ) ) { 
  464. $parent_attributes = array_filter( (array) get_post_meta( $product->get_id(), '_product_attributes', true ) ); 
  465.  
  466. if ( ! $children ) { 
  467. $children = $product->get_children( 'edit' ); 
  468.  
  469. foreach ( $children as $child_id ) { 
  470. $all_meta = get_post_meta( $child_id ); 
  471.  
  472. foreach ( $all_meta as $name => $value ) { 
  473. if ( 0 !== strpos( $name, 'attribute_' ) ) { 
  474. continue; 
  475. if ( sanitize_title( $value[0] ) === $value[0] ) { 
  476. foreach ( $parent_attributes as $attribute ) { 
  477. if ( 'attribute_' . sanitize_title( $attribute['name'] ) !== $name ) { 
  478. continue; 
  479. $text_attributes = wc_get_text_attributes( $attribute['value'] ); 
  480. foreach ( $text_attributes as $text_attribute ) { 
  481. if ( sanitize_title( $text_attribute ) === $value[0] ) { 
  482. update_post_meta( $child_id, $name, $text_attribute ); 
  483. break; 
  484.  
  485. /** 
  486. * Match a variation to a given set of attributes using a WP_Query. 
  487. * @deprecated 3.0.0 in favour of Product data store's find_matching_product_variation. 
  488. */ 
  489. public function get_matching_variation( $match_attributes = array() ) { 
  490. wc_deprecated_function( 'WC_Product::get_matching_variation', '3.0', 'Product data store find_matching_product_variation' ); 
  491. $data_store = WC_Data_Store::load( 'product' ); 
  492. return $data_store->find_matching_product_variation( $this, $match_attributes ); 
  493.  
  494. /** 
  495. * Returns whether or not we are showing dimensions on the product page. 
  496. * @deprecated 3.0.0 Unused. 
  497. * @return bool 
  498. */ 
  499. public function enable_dimensions_display() { 
  500. wc_deprecated_function( 'WC_Product::enable_dimensions_display', '3.0' ); 
  501. return apply_filters( 'wc_product_enable_dimensions_display', true ) && ( $this->has_dimensions() || $this->has_weight() || $this->child_has_weight() || $this->child_has_dimensions() ); 
  502.  
  503. /** 
  504. * Returns the product rating in html format. 
  505. * @deprecated 3.0.0 
  506. * @param string $rating (default: '') 
  507. * @return string 
  508. */ 
  509. public function get_rating_html( $rating = null ) { 
  510. wc_deprecated_function( 'WC_Product::get_rating_html', '3.0', 'wc_get_rating_html' ); 
  511. return wc_get_rating_html( $rating ); 
  512.  
  513. /** 
  514. * Sync product rating. Can be called statically. 
  515. * @deprecated 3.0.0 
  516. * @param int $post_id 
  517. */ 
  518. public static function sync_average_rating( $post_id ) { 
  519. wc_deprecated_function( 'WC_Product::sync_average_rating', '3.0', 'WC_Comments::get_average_rating_for_product or leave to CRUD.' ); 
  520. $average = WC_Comments::get_average_rating_for_product( wc_get_product( $post_id ) ); 
  521. update_post_meta( $post_id, '_wc_average_rating', $average ); 
  522.  
  523. /** 
  524. * Sync product rating count. Can be called statically. 
  525. * @deprecated 3.0.0 
  526. * @param int $post_id 
  527. */ 
  528. public static function sync_rating_count( $post_id ) { 
  529. wc_deprecated_function( 'WC_Product::sync_rating_count', '3.0', 'WC_Comments::get_rating_counts_for_product or leave to CRUD.' ); 
  530. $counts = WC_Comments::get_rating_counts_for_product( wc_get_product( $post_id ) ); 
  531. update_post_meta( $post_id, '_wc_rating_count', $counts ); 
  532.  
  533. /** 
  534. * Same as get_downloads in CRUD. 
  535. * @deprecated 3.0.0 
  536. * @return array 
  537. */ 
  538. public function get_files() { 
  539. wc_deprecated_function( 'WC_Product::get_files', '3.0', 'WC_Product::get_downloads' ); 
  540. return $this->get_downloads(); 
  541.  
  542. /** 
  543. * @deprected 3.0.0 Sync is taken care of during save - no need to call this directly. 
  544. */ 
  545. public function grouped_product_sync() { 
  546. wc_deprecated_function( 'WC_Product::grouped_product_sync', '3.0' );