-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the WC_Product classes from wp-ispconfig3 into wc folder
- Loading branch information
ole
committed
Apr 9, 2019
1 parent
f6f70ed
commit 2285b72
Showing
8 changed files
with
475 additions
and
20 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,14 @@ | |
/* | ||
* Plugin Name: WC Recurring Invoice PDF | ||
* Description: WooCommerce invoice pdf plugin with recurring payments (scheduled) | ||
* Version: 1.1.0 | ||
* Version: 1.4.0 | ||
* Author: ole1986 <[email protected]> | ||
* Author URI: https://github.com/ole1986/wc-invoice-pdf | ||
* Plugin URI: https://github.com/ole1986/wc-invoice-pdf/releases | ||
* Text Domain: wc-invoice-pdf | ||
* | ||
* WC requires at least: 3.0.0 | ||
* WC tested up to: 3.4.4 | ||
* WC tested up to: 3.5 | ||
*/ | ||
|
||
namespace WCInvoicePdf; | ||
|
@@ -74,9 +74,10 @@ class WCInvoicePdf { | |
public static function init() { | ||
self::load_textdomain_file(); | ||
|
||
if(file_exists(WCINVOICEPDF_PLUGIN_DIR . '../wp-ispconfig3/wc/ispconfig_wc_product.php')) { | ||
include_once WCINVOICEPDF_PLUGIN_DIR . '../wp-ispconfig3/wc/ispconfig_wc_product.php'; | ||
include_once WCINVOICEPDF_PLUGIN_DIR . '../wp-ispconfig3/wc/ispconfig_wc_product_webspace.php'; | ||
if(file_exists(WCINVOICEPDF_PLUGIN_DIR . 'wc/wc_product.php')) { | ||
include_once WCINVOICEPDF_PLUGIN_DIR . 'wc/wc_product.php'; | ||
include_once WCINVOICEPDF_PLUGIN_DIR . 'wc/wc_product_webspace.php'; | ||
include_once WCINVOICEPDF_PLUGIN_DIR . 'wc/wc_product_service.php'; | ||
} | ||
|
||
self::load_options(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
if (!class_exists('WC_Product')) { | ||
return; | ||
} | ||
|
||
add_filter('woocommerce_product_data_tabs', ['WC_ISPConfigProduct','hotfix_product_data_tabs'], 5); | ||
|
||
abstract class WC_ISPConfigProduct extends WC_Product | ||
{ | ||
abstract public function OnCheckout($checkout); | ||
abstract public function OnCheckoutValidate(); | ||
abstract public function OnCheckoutSubmit($order_id, $item_key, $item); | ||
|
||
public static function add_to_cart() | ||
{ | ||
wc_get_template('single-product/add-to-cart/simple.php'); | ||
} | ||
|
||
public static function hotfix_product_data_tabs($product_data_tabs) | ||
{ | ||
// HOTFIX: display the general pricing (even when switching back to simple products) | ||
$generalClasses = &$product_data_tabs['general']['class']; | ||
if (!in_array('show_if_simple', $generalClasses)) { | ||
$generalClasses[] = 'show_if_simple'; | ||
} | ||
if (!in_array('show_if_external', $generalClasses)) { | ||
$generalClasses[] = 'show_if_external'; | ||
} | ||
|
||
return $product_data_tabs; | ||
} | ||
|
||
public function is_purchasable() | ||
{ | ||
return true; | ||
} | ||
|
||
public function get_sold_individually($context = 'view') | ||
{ | ||
return true; | ||
} | ||
|
||
public function get_min_purchase_quantity() { | ||
return 1; | ||
} | ||
|
||
public function get_price($context = 'view') | ||
{ | ||
return $this->get_regular_price(); | ||
} | ||
|
||
/** | ||
* Get the add to url used mainly in loops. | ||
* | ||
* @return string | ||
*/ | ||
public function add_to_cart_url() | ||
{ | ||
$url = $this->is_purchasable() && $this->is_in_stock() ? remove_query_arg('added-to-cart', add_query_arg('add-to-cart', $this->id)) : get_permalink($this->id); | ||
return $url; | ||
} | ||
|
||
/** | ||
* Get the add to cart button text. | ||
* | ||
* @return string | ||
*/ | ||
public function add_to_cart_text() | ||
{ | ||
$text = $this->is_purchasable() && $this->is_in_stock() ? __('Add to cart', 'woocommerce') : __('Read more', 'woocommerce'); | ||
|
||
return apply_filters('woocommerce_product_add_to_cart_text', $text, $this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?php | ||
add_filter('woocommerce_product_data_tabs', ['WC_Product_Hour','hour_product_data_tab']); | ||
|
||
add_action('woocommerce_product_data_panels', ['WC_Product_Hour','product_data_fields']); | ||
add_action('woocommerce_process_product_meta_hour', ['WC_Product_Hour', 'metadata_save']); | ||
|
||
add_action('admin_footer', ['WC_Product_Hour', 'jsRegister']); | ||
add_filter('product_type_selector', ['WC_Product_Hour','register']); | ||
|
||
class WC_Product_Hour extends WC_Product | ||
{ | ||
public static $current; | ||
|
||
public function __construct($product) | ||
{ | ||
$this->product_type = 'hour'; | ||
parent::__construct($product); | ||
} | ||
|
||
public static function register($types) | ||
{ | ||
// Key should be exactly the same as in the class product_type parameter | ||
$types[ 'hour' ] = __('Working hours', 'wc-invoice-pdf'); | ||
return $types; | ||
} | ||
|
||
public static function jsRegister() | ||
{ | ||
global $product_object; | ||
?> | ||
<script type='text/javascript'> | ||
jQuery( document ).ready( function() { | ||
jQuery( '.options_group.pricing' ).addClass( 'show_if_hour' ).show(); | ||
<?php if ($product_object instanceof self) : ?> | ||
jQuery('.general_options').show(); | ||
jQuery('.general_options > a').trigger('click'); | ||
<?php endif; ?> | ||
}); | ||
</script> | ||
<?php | ||
} | ||
|
||
/** | ||
* Get the add to url used mainly in loops. | ||
* | ||
* @return string | ||
*/ | ||
public function add_to_cart_url() | ||
{ | ||
$url = $this->is_purchasable() && $this->is_in_stock() ? remove_query_arg('added-to-cart', add_query_arg('add-to-cart', $this->id)) : get_permalink($this->id); | ||
return $url; | ||
} | ||
|
||
/** | ||
* Get the add to cart button text. | ||
* | ||
* @return string | ||
*/ | ||
public function add_to_cart_text() | ||
{ | ||
$text = $this->is_purchasable() && $this->is_in_stock() ? __('Add to cart', 'woocommerce') : __('Read more', 'woocommerce'); | ||
|
||
return apply_filters('woocommerce_product_add_to_cart_text', $text, $this); | ||
} | ||
|
||
public static function hour_product_data_tab($product_data_tabs) | ||
{ | ||
$product_data_tabs['general']['class'][] = 'show_if_hour'; | ||
$product_data_tabs['linked_product']['class'][] = 'hide_if_hour'; | ||
$product_data_tabs['attribute']['class'][] = 'hide_if_hour'; | ||
$product_data_tabs['advanced']['class'][] = 'hide_if_hour'; | ||
$product_data_tabs['shipping']['class'][] = 'hide_if_hour'; | ||
|
||
$product_data_tabs['hour_tab'] = array( | ||
'label' => __('Working hours', 'wc-invoice-pdf'), | ||
'target' => 'hour_data_tab', | ||
'class' => 'show_if_hour' | ||
); | ||
|
||
return $product_data_tabs; | ||
} | ||
|
||
|
||
public static function product_data_fields() | ||
{ | ||
echo '<div id="hour_data_tab" class="panel woocommerce_options_panel">'; | ||
woocommerce_wp_checkbox(['id' => '_hour_useminute', 'label' => __('minutes', 'wc-invoice-pdf'), 'description' => __("To the minute calculation", 'wc-invoice-pdf')]); | ||
echo '</div>'; | ||
} | ||
|
||
/** | ||
* 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); | ||
} | ||
} |
Oops, something went wrong.