• Resolved leggo-my-eggo

    (@leggo-my-eggo)


    Hi there, very helpful plugin, thanks for all of your obvious hard work.

    Two things I’d like to know if are possible, and if not, add as feature requests:

    1. I want to use the “Add to Cart” button inside an iframe, but it doesn’t work because the target=”_parent” attribute would need to be set. Any way to do this?

    2. I’d like to be able to have the text on the Add to Cart button read something like “Add to Cart for $16.00”. Any ideas?

    Thanks again.

    https://wordpress.org/plugins/wordpress-simple-paypal-shopping-cart/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter leggo-my-eggo

    (@leggo-my-eggo)

    As a followup, rather than going through the pain of somehow adding these as front-end features, I’d be happy with the ability to override the print_wp_cart_button_for_product function, or a hook to filter the form results.

    Thread Starter leggo-my-eggo

    (@leggo-my-eggo)

    I just kind of quickly hacked something together as a suggestion. Here’s lines 633-648 of wp_shopping_cart.php

    $replacement .= '<form method="post" class="wp-cart-button-form" action="" style="display:inline" onsubmit="return ReadForm(this, true);"' . apply_filters('wp_cart_form_attr_filter', "") . '>';
        if (!empty($var_output)) {//Show variation
            $replacement .= '<div class="wp_cart_variation_section">' . $var_output . '</div>';
        }
    
        if (isset($atts['button_image']) && !empty($atts['button_image'])) {
            //Use the custom button image for this shortcode
            $replacement .= '<input type="image" src="' . $atts['button_image'] . '" class="wp_cart_button" alt="' . (__("Add to Cart", "WSPSC")) . '"/>';
        } else {
            //Use the button text or image value from the settings
            if (preg_match("/http:/", $addcart) || preg_match("/https:/", $addcart)) { // Use the image as the 'add to cart' button
                $replacement .= '<input type="image" src="' . $addcart . '" class="wp_cart_button" alt="' . (__("Add to Cart", "WSPSC")) . '"/>';
            } else {
                $replacement .= '<input type="submit" value="' . apply_filters('wp_cart_button_filter', $addcart, $price) . '" />';
            }
        }

    And then I can do something like:

    add_filter('wp_cart_form_attr_filter', 'add_parent_action_to_iframe_forms', 10, 2);
    function add_parent_action_to_iframe_forms($content) {
      return 'target="_parent"';
    }
    
    add_filter('wp_cart_button_filter', 'form_button_text', 10, 2);
    function form_button_text($addcart, $price) {
      return $addcart . " for $" . $price;
    }

    Whaddaya think? Do you think something like this could be incorporated?

    Plugin Contributor mbrsolution

    (@mbrsolution)

    Hi leggo-my-eggo, one of the plugin developers will get back to you on your suggestion above.

    Thank you

    Plugin Author mra13

    (@mra13)

    Hi, I have added the necessary filters in the plugin. So it will be available for you in the next version.

    Thread Starter leggo-my-eggo

    (@leggo-my-eggo)

    Excellent, thank you! Is there a dev version I can look at to see how you did it?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘iframe target action and add to cart button text’ is closed to new replies.