Skip to content

Instantly share code, notes, and snippets.

@marcusig
marcusig / inline-configuartor-loading-message.css
Created July 27, 2021 11:25
Inline configurator loading message
/* Code For Loading Screen */
@keyframes configurator-load {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
@marcusig
marcusig / fix-white-space.css
Created August 3, 2021 12:48
Fix white space in the configurator's buttons
.mkl_pc .mkl_pc_container .mkl_pc_toolbar section.choices li button {
white-space: normal;
}
@marcusig
marcusig / change-add-to-cart-label.php
Created September 22, 2021 13:12
Change the Add to cart label in the configurator
<?php
add_filter( 'mkl_pc/add_to_cart_button/default_label', function( $original_label ) {
return 'Continue to payment';
} );
@marcusig
marcusig / override-configurator-theme.php
Created October 12, 2021 13:09
Override the current Configurator theme using a postmeta
<?php
if ( ! defined( 'ABSPATH' ) ) die();
add_filter( 'mkl/pc/theme_id', function( $default ) {
global $post;
if ( ! is_a( $post, 'WP_Post' ) ) return $default;
// Example 1: use the post meta to get the theme
if ( get_post_meta( $post->ID, 'mkl_custom_page_theme', true ) ) return get_post_meta( $post->ID, 'mkl_custom_page_theme', true );
@marcusig
marcusig / show-selection-thumbnail-in-layer-header.js
Created October 20, 2021 05:23
Show the current choice's thumbnail in the layer's header
wp.hooks.addAction( 'PC.fe.layers_list_item.init', 'Antonio.selected.image', function( view ) {
var content = PC.fe.getLayerContent( view.model.id );
view.listenTo( content, 'change:active', function( choice_model, activated ) {
if ( activated ) {
var image = choice_model.get_image( 'thumbnail' );
if ( image ) {
view.$( '.layer-item .img' ).html( '<img src="' + image + '">' );
}
}
} );
@marcusig
marcusig / smaller-colors-thumbnails.css
Created October 26, 2021 08:20
Display the thumbnails smaller. Requires adding the class 'color-only' to the Layer
.mkl_pc .mkl_pc_container .mkl_pc_toolbar section.choices > ul > li.color-only .choices-list li {
box-shadow: none;
width: 11%;
}
.mkl_pc .mkl_pc_container .mkl_pc_toolbar section.choices > ul > li.color-only .choices-list li button span.choice-text {
position: absolute;
top: 100%;
left: 50%;
transform: translateX(-50%);
@marcusig
marcusig / html-support-in-the-choices.php
Created November 15, 2021 06:58
Product configurator - Add support for HTML in the choice labels
<?php
add_filter( 'tmpl-pc-configurator-choice-item-label', function( $original_label ) {
return '{{{data.name}}}';
}, 1 );
@marcusig
marcusig / add-cart-link.php
Created December 7, 2021 05:07
Add a link to the cart (quote)
@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;
@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%);
}