Skip to content

Instantly share code, notes, and snippets.

Avatar
💻

Mircea Sandu mircian

💻
View GitHub Profile
@mircian
mircian / woocommerce_simple_add_to_cart.js
Created Sep 29, 2018
Create a simple function which you can globally call to easily add a product to the cart by id.
View woocommerce_simple_add_to_cart.js
<script type="text/javascript">
function m_wc_add_to_cart( product_id ) {
if ( 'undefined' === typeof wc_add_to_cart_params ) {
// The add to cart params are not present.
return false;
}
var data = {
product_id: product_id,
View wp_admin_product_search_results_meta.php
/**
* Alter the query vars to include products which have the meta we are searching for.
*
* @param array $query_vars The current query vars.
*
* @return array
*/
function m_request_query( $query_vars ) {
global $typenow;
@mircian
mircian / class-m-custom-uploads-filename.php
Last active Dec 12, 2017
Change the name of files uploaded through the media uploader.
View class-m-custom-uploads-filename.php
<?php
/**
* Class M_Custom_Uploads_Filename
*/
class M_Custom_Uploads_Filename {
/**
* M_Custom_Uploads_Filename constructor.
*/
View wc_vendors_custom_percent_commission.php
<?php
add_filter('wcv_commission_rate', 'm_commission_update', 20, 5);
/**
* @param $commission
* @param $product_id
* @param $product_price
* @param $order
* @param $qty
@mircian
mircian / search_wp_index_woocommerce_variation_data.php
Created Sep 10, 2017
Add custom variation data to WooCommerce products in the SearchWP index. More details at https://mircian.com/2017/09/20/woocommerce-variation-data-searchwp/
View search_wp_index_woocommerce_variation_data.php
<?php
/**
* @param array $extra_meta
* @param WP_Post $post_being_indexed
*
* @return array
*/
function m_index_woocommerce_variation_isbn( $extra_meta, $post_being_indexed ) {
@mircian
mircian / m_hide_gateways.php
Last active May 29, 2018
Hide certain WooCommerce gateways from non-admin users
View m_hide_gateways.php
<?php
/**
* @param $available_gateways array of available WooCommerce gateways
*
* @return array Updated gateways
*/
function m_disable_gateways_for_loggedout_users( $available_gateways ) {
if ( ! is_user_logged_in() && ! current_user_can( 'manage_options' ) ) {
View print_this_example.html
<a href="#" class="wsl_print" data-target=".search-results">
Print element
</a>
View clipboard_js_example.html
<a href="javascript:void(0);" data-clipboard-text="This is the text to copy!" class="btn-copy">
<span class="m_copy_text">Copy Link</span>
</a>
View gform_sections_accordion.css
.m_collapse_text, .show_collapse .m_expand_text, .m_section{
display: none;
}
.show_collapse .m_collapse_text {
display: inline;
}
View gform_sections_accordion.css
.m_collapse_text, .show_collapse .m_expand_text, .m_section{
display: none;
}
.show_collapse .m_collapse_text {
display: inline;
}
You can’t perform that action at this time.