Skip to content

Instantly share code, notes, and snippets.

@patrickposner
patrickposner / functions.php
Created July 4, 2018 12:23
deactivate gutenberg plugin conditional
/**
* deactivate gutenberg and woocommerce products block plugins if activated
*/
add_action( 'admin_init', 'atomion_deactivate_gutenberg' );
function atomion_deactivate_gutenberg() {
if ( is_plugin_active('gutenberg/gutenberg.php') ) {
deactivate_plugins('gutenberg/gutenberg.php');
}
/* get rid of all information after item title and quantity */
add_filter( 'woocommerce_de_additional_item_string', 'gm_remove_each_information' );
function gm_remove_each_information( $return ) {
$return = '';
return $return;
}
public function dhvc_woo_product_page_price_shortcode( $atts, $content = null ) {
global $post, $product;
extract( $this->_shortcode_atts( array(
'el_class' => ''
), $atts ) );
ob_start();
/* "wp" is the earliest possible hook before rendering a page */
add_action( 'wp', 'disable_author_page' );
function disable_author_page() {
/* get global $wp_query object */
global $wp_query;
/* If an author page is requested, answer with 404
// Bestellstatus nach Stripe->Sofortüberweisung direkt auf fertiggestellt
add_action( 'woocommerce_thankyou', 'sofort_force_order_complete', 10, 1 );
function sofort_force_order_complete( $order_get_id ) {
$order = new WC_Order($order_get_id);
if($order->get_payment_method() == 'stripe_sofort') {
function atomion_get_posts_pagination( Array $args = array() ) {
global $wp_query;
$paginated = $wp_query->max_num_pages;
if ( $paginated < 2 )
return '';
$default_args = array(
class my_walker_nav_menu extends Walker_Nav_Menu {
static $count=0;
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
/* Add custom fields to quickster */
add_filter( 'quickster_filter_type', 'add_price', 10 );
function add_price( $custom ) {
/* thats your custom slug */
$custom = 'regular_price';
return $custom;
}
/* remember: the filter ends with your custom slug */
add_action( 'wp_footer', 'gm_output_rbp_meta' );
function gm_output_rbp_meta( $product_id ) {
$rbp_config = get_post_meta( $product_id, 'rbp_role_config' );
foreach ( $rbp_config as $group ) {
if ( 'b2b' == key( $group ) ) {
var_dump( $group['b2b']['bulk_price'] );
}
@patrickposner
patrickposner / functions.php
Last active August 30, 2018 06:27
Add additional information for customer group on single product template
add_action( 'woocommerce_single_product_summary', 'rbp_output_single_product_discount_information', 35 );
function rbp_output_single_product_discount_information() {
$group = get_user_meta( get_current_user_id(), 'customer_group', true );
if ( is_user_logged_in() === true && 'stammkunden' === $group ) {
$product = wc_get_product( get_the_id() );
if ( $product->is_type( 'variable' ) ) {