Skip to content

Instantly share code, notes, and snippets.

View titodevera's full-sized avatar
:bowtie:
Coding!

Alberto de Vera Sevilla titodevera

:bowtie:
Coding!
  • Soria
View GitHub Profile
@titodevera
titodevera / ps_webservice_functions.php
Created May 24, 2017 16:58
Prestashop Webservice helpful functions
/**
* 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
@titodevera
titodevera / gist:dbb979286408182e748b080a190805c5
Last active June 22, 2017 12:29
Update existing posts to random publication dates
$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
@titodevera
titodevera / pwb-terms.sql
Created July 10, 2017 21:45
Retrieve the brands for a product using SQL
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!!)
@titodevera
titodevera / class-custom-pwb-secondary-description.php
Created February 1, 2018 16:22
Adds secondary description field for brands taxonomy (Perfect WooCommerce Brands)
<?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(){
@titodevera
titodevera / export-sent-emails-addresses.php
Created December 19, 2018 09:09
Export sent email addresses to a CSV file
<?php
/*
* Export sent email addresses to a CSV file
*/
class Export_Sent_Emails_Addresses{
private $username, $pass, $imap_path;
@titodevera
titodevera / woo-quantity-dropdown.php
Last active May 8, 2019 07:09
Change WooCommerce add to cart quantity into a drop-down
<?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
*/
@titodevera
titodevera / fix-prague-firefox.txt
Created February 16, 2021 09:09
Fix for Prague 2.3.0 WordPress theme bugs on Firefox
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 );
@titodevera
titodevera / allow-external-urls.php
Created June 23, 2021 15:12
Perfect Brands for WooCommerce: Allow external URLs in brands banners
<?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;
@titodevera
titodevera / functions.php
Created December 27, 2021 19:30
Display WooCommerce product variations dropdown select on the shop, categories, catalog... pages
<?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' ) ) {