Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Adding an option to exclude products from selected product categories from applying the Call for Price feature. #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mokshasharmila13
Copy link
Collaborator

Fix #35.

…gories from applying the Call for Price feature.
Copy link
Collaborator

@tyche-bot tyche-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

⚠️ 5 warnings


hashes-api-scanning skipped

@@ -517,7 +513,12 @@ public function fetch_product_price_if_zero_or_empty( $price, $_product ) {
* @since 3.0.3
*/
public function make_empty_price( $price, $_product ) {
return $this->fetch_product_price_if_zero_or_empty( $price, $_product );
$exclude_products = get_option( 'alg_call_for_price_exclude_product', array() );
if ( in_array( $_product->id, $exclude_products ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Not using strict comparison for in_array; supply true for third argument (WordPress.PHP.StrictInArray.MissingTrueStrict).

return $price_hash;
}
}
if ( in_array( $_product->id, $exclude_products ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Not using strict comparison for in_array; supply true for third argument (WordPress.PHP.StrictInArray.MissingTrueStrict).

$exclude_products = get_option( 'alg_call_for_price_exclude_product', array() );
$categories = get_the_terms( $_product->id, 'product_cat' );
foreach ( $categories as $cat ) {
if ( in_array( $cat->term_id, $exclude_categories ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Not using strict comparison for in_array; supply true for third argument (WordPress.PHP.StrictInArray.MissingTrueStrict).

if ( ! empty( $product_terms ) ) {
foreach ( $product_terms as $product_term ) {
if ( in_array( (string) $product_term->term_id, $term_ids, true ) ) {
return '';
if ( in_array( $product_term->term_id, $exclude_categories ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Not using strict comparison for in_array; supply true for third argument (WordPress.PHP.StrictInArray.MissingTrueStrict).

@@ -398,15 +372,25 @@ public function make_empty_price_by_product_price( $price, $_product ) {
* @since 3.2.0
*/
public function make_empty_price_per_taxonomy( $price, $_product ) {

$exclude_products = get_option( 'alg_call_for_price_exclude_product', array() );
if ( in_array( $_product->id, $exclude_products ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Not using strict comparison for in_array; supply true for third argument (WordPress.PHP.StrictInArray.MissingTrueStrict).

@tyche-bot
Copy link
Collaborator

GitHub API communication error. Please contact a human. (commit-ID: b2a84b3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to exclude products from selected product categories from applying the Call for Price feature.
3 participants