class-wc-legacy-shipping-zone.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. exit;
  4. }
  5. /**
  6. * Legacy Shipping Zone.
  7. *
  8. * @version 3.0.0
  9. * @package WooCommerce/Classes
  10. * @category Class
  11. * @author WooThemes
  12. */
  13. abstract class WC_Legacy_Shipping_Zone extends WC_Data {
  14. /**
  15. * Get zone ID
  16. * @return int|null Null if the zone does not exist. 0 is the default zone.
  17. * @deprecated 3.0
  18. */
  19. public function get_zone_id() {
  20. wc_deprecated_function( 'WC_Shipping_Zone::get_zone_id', '3.0', 'WC_Shipping_Zone::get_id' );
  21. return $this->get_id();
  22. }
  23. /**
  24. * Read a shipping zone by ID.
  25. * @deprecated 3.0.0 - Init a shipping zone with an ID.
  26. *
  27. * @param int $zone_id
  28. */
  29. public function read( $zone_id ) {
  30. wc_deprecated_function( 'WC_Shipping_Zone::read', '3.0', 'a shipping zone initialized with an ID.' );
  31. $this->set_id( $zone_id );
  32. $data_store = WC_Data_Store::load( 'shipping-zone' );
  33. $data_store->read( $this );
  34. }
  35. /**
  36. * Update a zone.
  37. * @deprecated 3.0.0 - Use ::save instead.
  38. */
  39. public function update() {
  40. wc_deprecated_function( 'WC_Shipping_Zone::update', '3.0', 'WC_Shipping_Zone::save instead.' );
  41. $data_store = WC_Data_Store::load( 'shipping-zone' );
  42. try {
  43. $data_store->update( $this );
  44. } catch ( Exception $e ) {
  45. return false;
  46. }
  47. }
  48. /**
  49. * Create a zone.
  50. * @deprecated 3.0.0 - Use ::save instead.
  51. */
  52. public function create() {
  53. wc_deprecated_function( 'WC_Shipping_Zone::create', '3.0', 'WC_Shipping_Zone::save instead.' );
  54. $data_store = WC_Data_Store::load( 'shipping-zone' );
  55. try {
  56. $data_store->create( $this );
  57. } catch ( Exception $e ) {
  58. return false;
  59. }
  60. }
  61. }