PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.13
Timetics – Appointment Booking Calendar & Scheduling v1.0.13
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
timetics / core / integrations / woocommerce / product.php

product.php in Timetics – Appointment Booking Calendar & Scheduling 1.0.13, at core/integrations/woocommerce/product.php

46 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WooCommerce Product
4 *
5 * @package Timetics
6 */
7 namespace Timetics\Core\Integrations\Woocommerce;
8
9 /**
10 * WooCommerce Product class
11 */
12 class Product {
13 /**
14 * Creat product for woocommer
15 *
16 * @return bool
17 */
18 public function create( $meeting ) {
19 $product_id = $meeting->get_wc_product_id();
20
21 if ( $product_id ) {
22 $product = wc_get_product( $product_id );
23 } else {
24 $product = new \WC_Product_Simple ();
25 }
26
27 $product_category = get_term_by( 'slug', 'timetics-meeting', 'product_cat' );
28 $product_category_id = ! empty( $product_category ) ? $product_category->term_id : 0;
29
30 $product->set_name( $meeting->get_name() );
31 $product->set_short_description( $meeting->get_description() );
32 $product->set_price( $meeting->get_price() );
33 $product->set_status( 'publish' );
34 $product->set_category_ids( [$product_category_id] );
35
36 $product->update_meta_data( 'timetics_meeting_id', $meeting->get_id() );
37 $product_id = $product->save();
38
39 $meeting->update( [
40 'wc_product_id' => $product->get_id(),
41 ] );
42
43 return $product_id;
44 }
45 }
46