Skip to content

Instantly share code, notes, and snippets.

@marcusig
marcusig / ocean-wp-qty-buttons.php
Last active February 12, 2022 18:37
OceanWP add QTY buttons to the configurator
<?php
add_action( 'wp_enqueue_scripts', function() {
wp_add_inline_script( 'mkl_pc/js/product_configurator', "
// When the configurator starts, add the qty buttons
wp.hooks.addAction( 'PC.fe.start', 'MKL/PC/Conditional', function() {
if ( 'undefined' != typeof oceanwpWooCustomFeatures && oceanwpWooCustomFeatures.quantityButtons ) oceanwpWooCustomFeatures.quantityButtons.start();
}, 30 );
" );
@marcusig
marcusig / remove-configurable-plugin-from-cart.php
Created January 28, 2022 09:56
Remove configurable product from the cart
<?php
add_action( 'mkl_pc/added_linked_product_to_the_cart', function( $cart_item_key, $product_id ) {
WC()->cart->remove_cart_item( $cart_item_key );
// Add custom notice
wc_add_notice( '<a href="' . esc_url( wc_get_cart_url() ) . '" class="button wc-forward">' . esc_html__( 'View cart', 'woocommerce' ) . '</a>' . __(' Your dress design has been added to your cart.', 'product-configurator-custom-theme') );
// Prevent default notice
throw new Exception();
}, 20, 2 );
@marcusig
marcusig / order_received_item_thumbnail_image.php
Created January 20, 2022 05:06
Add the configuration image to the order received item
<?php
/**
* Display the product thumbnail in order received page
*/
function order_received_item_thumbnail_image( $item_name, $item, $is_visible ) {
// Targeting order received page only
if( ! is_wc_endpoint_url('order-received') ) return $item_name;
@marcusig
marcusig / add-sku-to-button.php
Created January 17, 2022 14:29
Add SKU to the choice button
<?php
add_filter( 'tmpl-pc-configurator-choice-item-label', function( $label ) {
return $label . ' <# if ( data.sku ) { #><span class="sku">{{data.sku}}</span><# } #>';
} );
@marcusig
marcusig / action-on-choice-change.js
Created January 17, 2022 12:50
JS Action to execute code when a choice is changed.
// Requires wp.hooks
// Make sure to set 'wp-hooks' and 'jquery' as dependencies when loading this script.
if ( ! wp || ! wp.hooks ) return;
( function( $ ) {
wp.hooks.addAction( 'PC.fe.choice.set_choice', 'Custom_domain', function( model, view ) {
// Do something here.
// view.$el will give you the jQuery object of the current choice.
} );
@marcusig
marcusig / current-layer-only.css
Created January 12, 2022 15:44
Only show the image of the currently opened layer
.mkl_pc .mkl_pc_container .mkl_pc_viewer .mkl_pc_layers *:not(.current_layer) {
opacity: 0;
}
@marcusig
marcusig / be-your-bag-tweaks.css
Created January 11, 2022 09:25
Be-your-bag tweaks
@media(max-width: 660px) {
.mkl_pc .mkl_pc_container footer button.configurator-add-to-cart span {
display: block;
}
button.primary.button.btn.btn-primary.configurator-add-to-cart {
background-color: #3bb54a !important;
margin-right: 4px;
}
@marcusig
marcusig / gamepcbestel.nl-tweaks.css
Last active February 26, 2022 05:40
CSS tweaks for gamepcbestel.nl
@media(min-width: 1000px) {
.mkl_pc {
/* Change this value to change the sidebar width */
--toolbar_width: 500px;
}
}
.mkl_pc .mkl_pc_container .mkl_pc_toolbar section.choices .layers button {
white-space: normal;
word-break: break-word;
@marcusig
marcusig / animate-layer-sideways.css
Created January 4, 2022 09:49
Animate a layer in and out when changing a selection.
/*
The Layer must have a specific class to target the images.
In this example, we use the class "bezel"
See it working on http://demos.mklacroix.com/configurable-watch/
*/
.mkl_pc .mkl_pc_container .mkl_pc_viewer .mkl_pc_layers img.bezel:not(.active) {
transform: translateX(calc(-50% - 300px)) translateY(-50%);
}
@marcusig
marcusig / mobile-fix-klartext.css
Created December 20, 2021 13:37
Change the display of the add to cart button on mobile
@media (max-width: 660px) {
.mkl_pc .mkl_pc_container .mkl-pc-show-form {
display: none;
}
.mkl_pc .mkl_pc_container footer .form.form-cart {
position: relative;
padding: 0;
background: transparent;
box-shadow: none;
border-radius: 0;