';
+ woocommerce_wp_checkbox(['id' => '_hour_useminute', 'label' => __('minutes', 'wc-invoice-pdf'), 'description' => __("To the minute calculation", 'wc-invoice-pdf')]);
+ echo '
';
+ }
+
+ /**
+ * BACKEND: Used to save the template ID for later use (Cart/Order)
+ */
+ public static function metadata_save($post_id)
+ {
+ update_post_meta($post_id, '_hour_useminute', $_POST['_hour_useminute']);
+ }
+
+ public function get_price_suffix($price = '', $qty = 1)
+ {
+ $plural = $qty > 1 ? 's' : '';
+ $suffix = __('Hour' . $plural, 'wc-invoice-pdf');
+
+ if($this->get_meta('_hour_useminute', true))
+ {
+ $suffix = __('minute' . $plural, 'wc-invoice-pdf');
+ }
+
+ return ' ' . $suffix;
+ }
+
+ public function get_price_html($price = '')
+ {
+ $price = wc_price(wc_get_price_to_display($this, array( 'price' => $this->get_regular_price() ))) . ' ' . __('per', 'wc-invoice-pdf') . $this->get_price_suffix('', 1);
+ return apply_filters('woocommerce_get_price_html', $price, $this);
+ }
+}
\ No newline at end of file
diff --git a/wc/wc_product_webspace.php b/wc/wc_product_webspace.php
new file mode 100644
index 0000000..189d2c7
--- /dev/null
+++ b/wc/wc_product_webspace.php
@@ -0,0 +1,232 @@
+ __('monthly', 'wc-invoice-pdf'), 'y' => __('yearly', 'wc-invoice-pdf') ];
+
+ $this->supports[] = 'ajax_add_to_cart';
+ //$this->product_type = "webspace";
+ parent::__construct($product);
+ }
+
+ public static function register($types)
+ {
+ $types[ 'webspace' ] = __('Webspace', 'wc-invoice-pdf');
+ return $types;
+ }
+
+ public static function jsRegister()
+ {
+ global $product_object;
+ ?>
+
+ __('ISPConfig 3', 'wp-ispconfig3'),
+ 'target' => 'ispconfig_data_tab',
+ 'class' => 'show_if_webspace'
+ );
+ }
+
+ return $product_data_tabs;
+ }
+
+ public static function ispconfig_product_data_fields()
+ {
+ if (!class_exists("Ispconfig")) return;
+ echo '';
+ try {
+ $templates = Ispconfig::$Self->withSoap()->GetClientTemplates();
+
+ $options = [0 => 'None'];
+ foreach ($templates as $v) {
+ $options[$v['template_id']] = $v['template_name'];
+ }
+ woocommerce_wp_select(['id' => '_ispconfig_template_id', 'label' => '
Client Limit Template', 'options' => $options]);
+
+ Ispconfig::$Self->closeSoap();
+ } catch (SoapFault $e) {
+ echo "
ISPConfig SOAP Request failed: " . $e->getMessage() . '
';
+ }
+
+ echo '
';
+ }
+
+ /**
+ * BACKEND: Used to save the template ID for later use (Cart/Order)
+ */
+ public static function webspace_metadata_save($post_id)
+ {
+ if (!empty($_POST['_ispconfig_template_id'])) {
+ update_post_meta($post_id, '_ispconfig_template_id', $_POST['_ispconfig_template_id']);
+ }
+ }
+
+ public function getISPConfigTemplateID()
+ {
+ return get_post_meta($this->get_id(), '_ispconfig_template_id', true);
+ }
+
+ public function OnCheckout($checkout)
+ {
+ $templateID = $this->getISPConfigTemplateID();
+
+ if ($templateID >= 1 && $templateID <= 3) {
+ echo "