We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Puzzle Order Button same TAB

Home Forums General Questions Puzzle Order Button same TAB

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #31755
    kubuz
    Customer

    Hi Guys,
    Very short and simple question.
    Is there a way to have the woo-commerce place order puzzle to open in the same tab.
    There is really no need to open it in a seperate tab.

    btw, I managed to drop the custom price the default cart.
    https://www.thecustomshop.be/custom-lamp-configurator/

    muchas gracias.

    #31761

    Hi,

    Awesome news! what plugin are you using for custom price?

    Is there a way to have the woo-commerce place order puzzle to open in the same tab.

    In fact, you can use just the puzzle send data to invoke that link (e.g. https://www.thecustomshop.be/winkelmand/?add-to-cart=1360)
    This way your page won’t be reloaded.

    Chief 3D Verger | LinkedIn | Twitter

    #31771
    kubuz
    Customer

    Awesome news! what plugin are you using for custom price?

    I was lucky that a good friend came to help me with this.
    Its a small piece of custom code in functions.php and a piece in MyAwesomeApp.js

    Basicly its pretty simple, I use a small custom script to create and update a cookie in the MyAwesomeApp.js

    function prepareExternalInterface(app) {
      app.ExternalInterface.setCookie = function setCookie(numericArg) {
        var d = new Date();
        d.setTime(d.getTime() + (5*24*60*60*1000));
        var expires = "expires="+ d.toUTCString();
        document.cookie = "Price" + "=" + numericArg + ";" + expires + ";path=/";
      }

    This cookie is being picked up by the script when entering the woocommerce cart page

    // PART 1, CHANGE PRICE OR CUSTOM PRODUCT ON THE CHECKOUT PAGE
    // ADD TO FUNCTIONS.PHP
    
    function custom_shop_price( $cart ) {
    
        $customshop_product_ids = 1360;
     
        if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
     
     
        // LOOP THROUGH CART ITEMS, FIND CUSTOM MADE PRODUCT, GET THE PRICE
      
    		
    		foreach (  WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
    			$product = $cart_item['data'];
    
    			// CHECK IF PRODUCT IS CUSTOM SHOP ITEM
    			if($product->id ==  $customshop_product_id && isset($_COOKIE['Price'])){
    				$cart_item['data']->set_price( $_COOKIE['Price'] );
    
    			// SET PRICE TO CUSTOM PRODUCT PRICE
    			// TODO: FIND THE STORED PRICE: SESSION, COOKIE, URL VARIABLE, ...??
    
    				$cart_item['data']->set_price( $_COOKIE['Price'] );
    			}
    		}
    	
     
    };
    add_action( 'woocommerce_before_calculate_totals', 'custom_shop_price' );
    
    // Clear Cart URL command
    function woocommerce_clear_cart_url() {
    	if ( isset( $_GET['add-to-cart'] ) ) {
    		WC()->cart->empty_cart();
    	}
    }
    add_action( 'init', 'woocommerce_clear_cart_url' );

    Now I still needs an update to handle multiple products.
    So we need to make this piece looping trough multiple products.

    #31773

    I see. Glad you worked it out, and thanks for sharing your solution! :good:

    Chief 3D Verger | LinkedIn | Twitter

    #70086
    meumobbi
    Participant

    In fact, you can use just the puzzle send data to invoke that link (e.g. https://www.thecustomshop.be/winkelmand/?add-to-cart=1360)
    This way your page won’t be reloaded.

    Hello, Yuri and all.

    I’ve encountered the same issue, but I don’t quite understand this answer you gave. No matter what I do, the puzzle always opens the URL in a new tab. I tried altering the following code in the “placeOrder” function in visual_logic.js:

    form.setAttribute(‘target’, ‘v3d_view’);

    TO:
    form.setAttribute(‘target’, ‘_top);

    That worked, but it’s useless since every time I save the puzzles, it overwrites this file.

    Could anyone please help me get this puzzle to open the URL in the same browser tab?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.