We managed to put a custom field for variation products following Remi Corson guide here At this point, we are able to show the custom text field in the single product page when users select the …
WooCommerce buy one get one 50% off, excluding a product variation
I am using WooCommerce discount: buy one get one 50% off with a notice answer code, if customer purchases a specific product, customer get 50% discount off on the 2nd item. Now If the targeted product id is a variable product with for example 3 variations “A”, “B” and “C”, …
Laravel/Lumen MemcachedStore calculateExpiration method (memcached set with unixtimestamp)
In core I have aforementioned class (MemcachedStore), which has put method as: $a = $this->memcached->set( $this->prefix.$key, $value, $this->calculateExpiration($…
Find date diff output as each year
Now I use date_diff() to find diff of date public function getDateDiff($date1,$date2){ $date1 = date_create(‘2019-12-29’); $date2 = date_create(‘2020-01-05’); $diff = date_diff($date1,$…
MySQL, PHP – WHERE clause
I create query as below, but I have a problem with WHERE part: So if I have products i.e.: DB Fiddle APPLE belonging to the categories: FRUIT, GREEN, ROUND WHEEL belonging to the categories: MACHINES, BLACK, ROUND BANANA belonging to the categories: FRUIT, YELLOW, CUBOID PHONE belonging to the categories: ELE…
Laravel: How to insert multiple data with select2 to mysql database?
I am trying to insert data into database. But i don’t know how to insert multi select data into the mysql database. enter image description here
<select …
Search a file for a string and replace everything after a character in that line
I am looking to use PHP to open a file (see example below), search it line by line for a string $colour and replace everything after the = with $value. file.txt before: If my $value is “1” and my colour is “blue”, my file should change to: My code so far is: However this only gets as f…
Laravel tap into moment before query execution
I am using Laravel scopes to limit what the end user can see based on some provided input, however with my current use-case this is no longer acceptable. Before applying additional queries, I would …
Prepend SVG icon before WooCommerce message
I want to prepend an SVG icon to the Add to Cart message in WooCommerce, but for some reason the SVG is not shown in the message. I have the following code in my functions.php file: function …
Remove blacklisted terms from string then eliminate unnecessary spaces
I have an array of blacklisted terms: and I have a string to sanitize: I just want to remove the $arrayBlacklist value if it’s in the $city variable. So, I get $city = “Jakarta Selatan” Answer Sort the array based on string length to avoid overlapping issues using usort. preg_replace each of…