Skip to content

Commit

Permalink
PHP Notices in server error logs, ref #723
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Jun 1, 2017
1 parent 1cc6c97 commit b5fd534
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 29 deletions.
1 change: 0 additions & 1 deletion angelleye-includes/angelleye-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,6 @@ public function ec_add_log($message, $level = 'info') {
if (empty($this->log)) {
$this->log = wc_get_logger();
}
$this->log->add(str_replace("_", "-", $this->payment_method), $message);
$this->log->log($level, $message, array('source' => $this->payment_method));
}
}
Expand Down
11 changes: 3 additions & 8 deletions classes/wc-gateway-calculations-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function cart_calculation() {
$product = $values['data'];
$name = $product->get_name();
}
$name = $this->clean_product_title($name);
$name = AngellEYE_Gateway_Paypal::clean_product_title($name);
$product_sku = null;
if (is_object($product)) {
$product_sku = $product->get_sku();
Expand Down Expand Up @@ -119,7 +119,7 @@ public function order_calculation($order_id) {
} else {
$name = $values['name'];
}
$name = $this->clean_product_title($name);
$name = AngellEYE_Gateway_Paypal::clean_product_title($name);
$amount = round($values['line_subtotal'] / $values['qty'], $this->decimals);
$item = array(
'name' => html_entity_decode( wc_trim_string( $name ? $name : __( 'Item', 'woocommerce' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
Expand Down Expand Up @@ -241,12 +241,7 @@ public function order_re_calculate($order) {
}
}

public function clean_product_title($product_title) {
$product_title = strip_tags($product_title);
$product_title = str_replace(array("–", "&#8211"), array("-"), $product_title);
$product_title = str_replace('&', '-', $product_title);
return $product_title;
}


}
endif;
8 changes: 4 additions & 4 deletions classes/wc-gateway-paypal-pro-payflow-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ function __construct() {
}


public function add_log($message) {
public function add_log($message, $level = 'info') {
if ($this->debug) {
if (!isset($this->log)) {
$this->log = new WC_Logger();
$this->log = wc_get_logger();
}
$this->log->add('paypal_payflow', $message);
$this->log->log( $level, $message, array( 'source' => 'paypal_pro_payflow' ) );
}
}

Expand Down Expand Up @@ -185,7 +185,7 @@ function init_form_fields() {
'type' => 'checkbox',
'label' => __('Enable logging', 'paypal-for-woocommerce'),
'default' => 'no',
'description' => sprintf(__('Log PayPal events inside <code>%s</code>', 'paypal-for-woocommerce'), wc_get_log_file_path('paypal_payflow')),
'description' => sprintf(__('Log PayPal events inside <code>%s</code>', 'paypal-for-woocommerce'), wc_get_log_file_path('paypal_pro_payflow')),
),
'error_email_notify' => array(
'title' => __('Error Email Notifications', 'paypal-for-woocommerce'),
Expand Down
48 changes: 32 additions & 16 deletions paypal-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,27 +537,36 @@ public static function calculate($order, $send_items = false){
* Get product data from WooCommerce
*/
if ($order) {
$_product = $order->get_product_from_item($item);
$qty = absint($item['qty']);
$item_meta = new WC_Order_Item_Meta($item,$_product);
$meta = $item_meta->display(true, true);
} else {
$_product = $item['data'];
$product = $order->get_product_from_item($item);
$sku = null;
if (is_object($product)) {
$sku = $product->get_sku();
}
if( empty($item['name']) ) {
$name = 'Item';
} else {
$name = $item['name'];
}
$name = self::clean_product_title($name);
$qty = absint($item['quantity']);
$meta = WC()->cart->get_item_data($item, true);
}
$sku = $_product->get_sku();
$item['name'] = html_entity_decode($_product->get_title(), ENT_NOQUOTES, 'UTF-8');
if ($_product->is_type('variation')) {
if (empty($sku)) {
$sku = $_product->parent->get_sku();
} else {
if (version_compare(WC_VERSION, '3.0', '<')) {
$product = $item['data'];
$name = $item['data']->post->post_title;
} else {
$product = $item['data'];
$name = $product->get_name();
}
if (!empty($meta)) {
$item['name'] .= " - " . str_replace(", \n", " - ", $meta);
$name = self::clean_product_title($name);
$sku = null;
if (is_object($product)) {
$sku = $product->get_sku();
}
$qty = absint($item['quantity']);
}

$Item = array(
'name' => $item['name'], // Item name. 127 char max.
'name' => html_entity_decode( wc_trim_string( $name ? $name : __( 'Item', 'woocommerce' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), // Item name. 127 char max.
'desc' => '', // Item description. 127 char max.
'amt' => self::number_format(self::round( $item['line_subtotal'] / $qty)), // Cost of item.
'number' => $sku, // Item number. 127 char max.
Expand Down Expand Up @@ -1323,6 +1332,13 @@ public function angelleye_paypal_for_woocommerce_page_title($page_title) {
return $page_title;
}
}

public static function clean_product_title($product_title) {
$product_title = strip_tags($product_title);
$product_title = str_replace(array("&#8211;", "&#8211"), array("-"), $product_title);
$product_title = str_replace('&', '-', $product_title);
return $product_title;
}
}
}
new AngellEYE_Gateway_Paypal();

0 comments on commit b5fd534

Please sign in to comment.