PluginProbe
MakeCommerce for WooCommerce / 4.0.8
MakeCommerce for WooCommerce v4.0.8
4.1.0 4.0.8 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.2 All 96 releases
makecommerce / makecommerce / shipping / product.php

product.php in MakeCommerce for WooCommerce 4.0.8, at makecommerce/shipping/product.php

68 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MakeCommerce\Shipping;
4
5 /**
6 * All functionality that has to do with shipping and products
7 *
8 * @since 3.0.0
9 */
10
11 class Product extends \MakeCommerce\Shipping {
12
13 private $loader;
14
15 /**
16 * Constructs Label class, defines loader and hooks
17 *
18 * @since 3.0.0
19 */
20 public function __construct( \MakeCommerce\Loader $loader ) {
21
22 $this->loader = $loader;
23
24 $this->define_hooks();
25 }
26
27 /**
28 * Define all wordpress hooks needed for printing stuff and creating labels
29 *
30 * @since 3.0.0
31 */
32 public function define_hooks() {
33
34 $this->loader->add_filter( 'woocommerce_product_options_shipping', $this, 'option_fields' );
35 $this->loader->add_filter( 'woocommerce_process_product_meta', $this, 'save' );
36 }
37
38 /**
39 * Save product fields
40 *
41 * @since 3.0.0
42 */
43 public function save( $post_id ) {
44 $no_parcel_machine = isset($_POST['_no_parcel_machine']) ? 'yes' : 'no';
45 update_post_meta($post_id, '_no_parcel_machine', $no_parcel_machine);
46
47 }
48
49 /**
50 * Add options to product page
51 *
52 * @since 3.0.0
53 */
54 public function option_fields( $fields ) {
55
56 echo '<div class="options_group">';
57
58 woocommerce_wp_checkbox(
59 array(
60 'id' => '_no_parcel_machine',
61 'label' => __('Does not fit parcel machine', 'wc_makecommerce_domain'),
62 'description' => __('When this is checked, parcel machine shipping option is not available for a cart with this product', 'wc_makecommerce_domain')
63 )
64 );
65
66 echo '</div>';
67 }
68 }