Home Forums WoodMart support forum Sticky Add to Cart feature code duplication messes with other plugins

Sticky Add to Cart feature code duplication messes with other plugins

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #658482

    markus
    Participant

    Hello,

    I don’t have all the specifics yet, but let’s maybe try without preparing a massive analysis of this all first.

    I am using https://www.studiowombat.com/plugin/advanced-product-fields-for-woocommerce/ and also addon’s for Live Content Preview https://www.studiowombat.com/plugin/live-content-preview-add-on/

    There are issues when it comes to replacing the product image. The Studio Wombat plugins allow to add custom fields to a product. Based on that, it’s also possible to change the product image shown, e.g. visitor selects from the field “Motive” the “star” icon then a preview image with a star will be shown, visitor selects from the field “Motive” the “heart” icon then a preview image with a heart will be shown.

    This works reliably with WoodMart Sticky Add to Cart disabled. This does not work reliably with WoodMart Sticky Add to Cart enabled.

    The Studio Wombat support says the following about it:
    >> The issue is that Woodmart just copies everything in the “add to cart” form and sticks it to the bottom. That means our fields and logic are also copied and so the plugin “runs twice” on one page and this can cause all sorts of problems.

    I could prepare all possible videos for you to demonstrate the issue, but if what Studio Wombat says i correct, then it’ll explain already the source of the problem.

    What do you think of this?

    Thanks

    best regards
    Markus

    #658534

    Luke Nielsen
    Keymaster

    Hello,

    We are encountering this issue with a simple product for the first time. So if you really need a sticky add to cart with this plugin, you need to copy the woodmart_sticky_single_add_to_cart function from inc/integrations/woocommerce/template-tags.php to your child theme and replace these lines in it:

    <?php if ( $product->is_type( 'simple' ) ) : ?>
    							<?php woocommerce_simple_add_to_cart(); ?>
    						<?php elseif ( $product->is_type( 'external' ) ) : ?>
    							<?php woocommerce_external_add_to_cart(); ?>
    						<?php else : ?>
    							<a href="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="wd-sticky-add-to-cart button alt<?php echo woodmart_get_old_classes( ' woodmart-sticky-add-to-cart' ); ?>">
    								<?php echo true == $product->is_type( 'variable' ) ? esc_html__( 'Select options', 'woodmart' ) : $product->single_add_to_cart_text(); ?>
    							</a>
    							<?php Quick_Buy::get_instance()->output_quick_buy_button(); ?>
    						<?php endif; ?>

    to the ones below:

    <a href="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="wd-sticky-add-to-cart button alt<?php echo woodmart_get_old_classes( ' woodmart-sticky-add-to-cart' ); ?>">
    								<?php echo true == $product->is_type( 'variable' ) ? esc_html__( 'Select options', 'woodmart' ) : $product->single_add_to_cart_text(); ?>
    							</a>
    							<?php Quick_Buy::get_instance()->output_quick_buy_button(); ?>

    Kind Regards

Viewing 2 posts - 1 through 2 (of 2 total)