This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Update the stock of a product after create it through the api | |
* Tested on PrestaShop 1.7.1.1 | |
* | |
* @link https://github.com/haka002/PrestaShop-webservice-lib PrestaShop 1.7 WebService lib | |
* | |
* @param SimpleXMLElement $product | |
* @param int $quantity | |
* | |
* @return void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$posts = get_posts( | |
array( | |
'numberposts' => -1, | |
'post_status' => 'any', | |
'post_type' => 'post' //you can use a cpt | |
) | |
); | |
foreach( $posts as $post ) { | |
//Generate a random date between 1 May 2017 and now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT t.*, tt.* FROM wp_terms AS t | |
INNER JOIN wp_term_taxonomy AS tt ON (tt.term_id = t.term_id) | |
INNER JOIN wp_term_relationships AS tr ON (tr.term_taxonomy_id = tt.term_taxonomy_id) | |
WHERE tt.taxonomy IN ('pwb-brand') AND tr.object_id IN (¡¡PRODUCT ID GOES HERE!!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds a secondary description field to brands | |
*/ | |
class Custom_PWB_Secondary_Description{ | |
static $field_name = 'Secondary description'; | |
static $field_desc = 'Here is the secondary description'; | |
function __construct(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Export sent email addresses to a CSV file | |
*/ | |
class Export_Sent_Emails_Addresses{ | |
private $username, $pass, $imap_path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Output the quantity input for add to cart forms. | |
* | |
* @param array $args Args for the input. | |
* @param WC_Product|null $product Product. | |
* @param boolean $echo Whether to return or echo|string. | |
* | |
* @return string | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Follow this steps (DEVELOPERS ONLY!) to solve on load bugs in Firefox for the Prague WordPress theme. | |
1) Copy the "all.js" file from parent (/prague/assets/js/all.js) to child theme (/prague-child/all.js) | |
2) Add this code to your "/prague-child/functions.php" | |
add_action( 'wp_enqueue_scripts', function() { | |
wp_enqueue_script( 'prague-theme-js', get_stylesheet_directory_uri() . '/all.js', [ 'jquery' ], '6.6.6', true ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'site_url', function( $url ) { | |
if ( ! is_tax( 'pwb-brand' ) ) return $url; | |
preg_match( '/http(s)?:\/\/.*(?=http(s)?)/', $url, $matches ); | |
if ( ! empty( $matches[0] ) ) $url = str_replace( $matches[0], '', $url ); | |
return $url; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display WooCommerce product variations dropdown select on the shop, categories, catalog... pages | |
* Tested on WordPress 5.8.2 + WooCommerce 5.9.0 + Storefront 3.9.1 + PHP 7.3.11 | |
* | |
* Alberto de Vera Sevilla <[email protected]> | |
*/ | |
add_filter( 'woocommerce_loop_add_to_cart_link', function( $html, $product ) { | |
if ( $product->is_type( 'variable' ) ) { |