• Resolved JJ

    (@jjtristargroup)


    Hi Jeroen,

    (I hope Dutch is okay to use here, let me know otherwise!)

    Ten eerst, geweldige plug-in! Zelf gebruikte ik eerst handgemaakte snippets in m’n function.php bestand maar dit was vervelend om telkens bij te moeten houden.
    Met jouw plug-in kan dit allemaal netjes via de UI worden gedaan, dus hartstikke bedankt hiervoor.

    Nu dan het probleem wat ik tegenkwam, ik gebruik 2 regels in 1 conditie. De 1e regel is “Country == Duitsland” en de 2e is “Contains product != Power Wipes”.
    (Ik neem aan dat dit duidelijk is voor jou maar ik leg het hieronder nog een keer uitgebreid uit ter duidelijkheid.)

    Deze regel zorgt ervoor dat zodra er producten in de winkelmand zitten welk niet “Power Wipes” zijn en het land Duitsland is er niet afgerekend kan worden. Maar nu is het zo dat als er producten in de winkelmand zitten welk niet “Power Wipes” zijn naast het “Power Wipes” product (wat dus ook in de mand zit) er wel afgerekend kan worden.

    Technisch gezien werkt deze regel gewoon zoals het hoort, alleen zou ik het graag zo hebben dat er een nieuwe regel word toegevoegd welk kan checken of er alleen 1 specifiek product in de winkelmand zit (en dus geen andere producten).

    Dit heb ik nu zelf toegevoegd (want deadlines ;)) via deze manier:

    1. Het bestand “\advanced-shipping-validation-for-woocommerce\libraries\wp-conditions\conditions\wpc-contains-product-condition.php” geopend.
    2. De functie match() aangepast.

    De nieuwe match() functie van dit bestand (welk ik dus zelf heb aangepast):

    public function match( $match, $operator, $value ) {
    
    			$product_ids = $this->get_compare_value();
    			$products_in_cart = count($product_ids) / 2;
    
    			if ( '==' == $operator ) :
    				$match = ( in_array( $value, $product_ids ) );
    			elseif ( '!=' == $operator ) :
    				if(in_array( $value, $product_ids ) && $products_in_cart == 1) {
    					$match = false;
    				} else {
    					$match = true;
    				}
    			endif;
    
    			return $match;
    
    		}

    Ik heb dus toegevoegd een regel om het aantal items in de mand te tellen en in de elseif statement check ik eerst of het product in de mand zit en of de hoeveelheid 1 is.

    Zo ver ik heb getest lijkt dit perfect te werken maar dit kan jij als developer natuurlijk veel beter weten dan ik.

    Dus mijn vraag is of dit toegevoegd kan worden, zodat ik niet elke keer het opnieuw moet toevoegen bij updates van de plug-in.

    Hoor graag wat je erover denkt!

    Met vriendelijke groet,
    Jan

    • This topic was modified 4 years, 4 months ago by JJ.
    • This topic was modified 4 years, 4 months ago by JJ.
Viewing 1 replies (of 1 total)
  • Plugin Author Jeroen Sormani

    (@sormano)

    Hi Jan,

    This is not something that can be added to the base plugin, but it is possible to create a custom condition that would fit your requirements.

    If you’d like me to create such customization, feel free to reach out through my site.

    Cheers,
    Jeroen

Viewing 1 replies (of 1 total)
  • The topic ‘New Condition Rule’ is closed to new replies.