Skip to content

Commit

Permalink
Merge pull request #32 from angelleye/PFWMA-93
Browse files Browse the repository at this point in the history
Product categories issue, PFWMA-93
  • Loading branch information
kcppdevelopers authored Dec 23, 2019
2 parents 2db297e + 9f0e5fa commit 184e831
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ public function angelleye_get_account_for_ec_parallel_payments($gateways, $gatew
$this->map_item_with_account[$product_id]['multi_account_id'] = 'default';
}
$woo_product_categories = wp_get_post_terms($product_id, apply_filters('angelleye_get_product_categories', array('product_cat')), array('fields' => 'ids'));
$woo_product_categories = angelleye_get_product_cat($woo_product_categories);
$product_categories = get_post_meta($value->ID, 'product_categories', true);
if (!empty($product_categories)) {
if (!array_intersect($product_categories, $woo_product_categories)) {
Expand Down Expand Up @@ -324,6 +325,7 @@ public function angelleye_get_account_for_ec_parallel_payments($gateways, $gatew
$this->map_item_with_account[$product_id]['multi_account_id'] = 'default';
}
$woo_product_categories = wp_get_post_terms($product_id, apply_filters('angelleye_get_product_categories', array('product_cat')), array('fields' => 'ids'));
$woo_product_categories = angelleye_get_product_cat($woo_product_categories);
$product_categories = get_post_meta($value->ID, 'product_categories', true);
if (!empty($product_categories)) {
if (!array_intersect($product_categories, $woo_product_categories)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public function angelleye_get_multi_account_by_order_total_latest($gateways, $ga
$product_id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
// Categories
$woo_product_categories = wp_get_post_terms($product_id, apply_filters('angelleye_get_product_categories', array('product_cat')), array('fields' => 'ids'));
$woo_product_categories = angelleye_get_product_cat($woo_product_categories);
$product_categories = get_post_meta($value->ID, 'product_categories', true);
if (!empty($product_categories)) {
if (!array_intersect($product_categories, $woo_product_categories)) {
Expand Down Expand Up @@ -249,6 +250,7 @@ public function angelleye_get_multi_account_by_order_total_latest($gateways, $ga
$product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key);
// Categories
$woo_product_categories = wp_get_post_terms($product_id, apply_filters('angelleye_get_product_categories', array('product_cat')), array('fields' => 'ids'));
$woo_product_categories = angelleye_get_product_cat($woo_product_categories);
$product_categories = get_post_meta($value->ID, 'product_categories', true);
if (!empty($product_categories)) {
if (!array_intersect($product_categories, $woo_product_categories)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public function angelleye_woocommerce_paypal_args($request, $order) {
}
$product_id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
$woo_product_categories = wp_get_post_terms($product_id, apply_filters('angelleye_get_product_categories', array('product_cat')), array('fields' => 'ids'));
$woo_product_categories = angelleye_get_product_cat($woo_product_categories);
$product_categories = get_post_meta($value->ID, 'product_categories', true);
if (!empty($product_categories)) {
if (!array_intersect($product_categories, $woo_product_categories)) {
Expand Down
18 changes: 18 additions & 0 deletions includes/angelleye-multi-account-function.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

function angelleye_get_product_cat($categories) {
$all_categories = array();
if (!empty($categories)) {
foreach ($categories as $key => $value) {
$all_categories[] = $value;
$term_object = get_term($value, 'product_cat');
if (!empty($term_object->parent)) {
$all_categories[] = $term_object->parent;
}
}
if (!empty($all_categories)) {
return $all_categories;
}
}
return $categories;
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private function load_dependencies() {
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-paypal-for-woocommerce-multi-account-management-i18n.php';
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-paypal-for-woocommerce-multi-account-management-wp-list-table.php';
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-paypal-for-woocommerce-multi-account-management-list-data.php';
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/angelleye-multi-account-function.php';



Expand Down

0 comments on commit 184e831

Please sign in to comment.