Home › Forums › General Questions › Puzzle Order Button same TAB
Tagged: addon, order page, puzzle, woocommerce
- This topic has 4 replies, 3 voices, and was last updated 10 months, 3 weeks ago by Brameister.
-
AuthorPosts
-
2020-08-19 at 9:57 pm #31755kubuzCustomer
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.
2020-08-20 at 7:03 am #31761Yuri KovelenovStaffHi,
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.2020-08-20 at 8:34 am #31771kubuzCustomerAwesome 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.jsBasicly 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.2020-08-20 at 8:51 am #31773Yuri KovelenovStaff2024-02-01 at 12:47 pm #70086BrameisterParticipantIn 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?
-
AuthorPosts
- You must be logged in to reply to this topic.