WP How to move a button in another position by php function - php

What is the best way to reposition the "Empty Cart" button on the checkout in Woocommerce. Ideally, in a non-destructive way that respects the JS on the page refreshing the table.
OP Cannot find correct documentation in native language
Original post:
I apologize immediately for the question. For many it will be
nonsense, but for me who is a beginner no. I need to move the empty
cart button next to the add to cart button. Through Google Inspect I
manage in 1 second to position the button where I want, but I can't do
it then through PHP in Wordpress. Sorry also for my english.
Thank you.

Related

Displaying PHP result in the same page

I want to add custom PHP to my wordpress site.
I managed to do it but the result is displayed in another page and it is just simple text.
I created simple calculator, and when user hits submit I want a div with the result to occur right below this calculator.
What is the simple way to do it or where can I seek some advice? Couldn't find it on google.
PS I am using wordpress themes so I added the action for the form as another file.
You could use javascipt to toggle visibility of your calendar div after response or add your custom div into response. You didn't wrote much. At first you should check out what is AJAX and find out where your response is creating.
If you didn't choose to add that for response, you can simple add PHP block to your templates files with <?php ... ?>.
Good luck! :)

Is there any way in PHP to detect if request is coming from browser back button?

I'm working on wordpress plugin, which handles shopping cart. I have two pages, checkout and thank you page. Items to cart are added by link like that https://mysite.com/checkout/?action=add&subscription=23 . I'm using Session for adding items to the cart on checkout page.
Suppose if I add three items added:
https://mysite.com/checkout/?action=add&subscription=1
https://mysite.com/checkout/?action=add&subscription=2
https://mysite.com/checkout/?action=add&subscription=3 (Last link in browser addressbar)
When user checkout on checkout page then user is redirected to thank you page. I have problem with browser back button, If user press back button on thank you, he is redirected again to checkout page with last item again added (https://mysite/checkout/?action=add&subscription=3 ) since this was the last link in browser address bar.
How can i prevent browser to add last item again on user back button press on thank you page?
Is there any way in PHP to detect if request is coming from browser back button? I think, there can be way to handle it using session?
Please guide me if there is any other suitable way to accomplish this? Thanks
The best way to handle that is to use the POST/REDIRECT/GET pattern.
Use Post Redirect Get design pattern.
In other words, the script that processes is not the one that displays the results.
You can user
$_SERVER['HTTP_REFERER'] to see your parent page, and detect if user is coming from thank you page

Back button on pages with tabs

I'm doing a system where the pages are displayed by tabs (easytabs Plugin http://os.alfajango.com/easytabs/#tabs1-js)
At one point in the process it performs a query in the database, where we
see all the details of each item that appears. I'd like to go into the details of the item, click back to the (on broswer or a button) the page to return to the list displayed by the SQL query, just as with any single page, but currently it only displays a blank page.
I wonder how can I do to implement this solution using the layout tabs.
Thank you.
There are various ways to maintain UI state. One of them is using a "url hash". For example, you click tab 2, change the url hash to:
mypage.php#tab=2
Then if someone presses BACK and goes FORWARD, you use JavaScript to look at the URL has and determine that the user had previously pressed tab 2, so you run your own bit of code that triggers the same event.
I'm unfamiliar with "easytabs" so I'm sorry I can't help with the specific implementation details, but that's the gist of the technique.

How do I make the iframe(child) from another iframe(parent) bigger than the its parent?

I'm creating a Purchase Order form in PHP and Fancybox and I'm having a hard time making a UI wherein inside a page the user can select a supplier and then after that a hyperlink will appear that will allow the user to add an item and once clicked another modal window is shown where a form containing the list of items are displayed as well as the quantity.
I was already able to do all the php coding correctly my problem now is that once I open the first Iframe the second Iframe becomes very small(which is what is expected because of the script 'width' and 'height'). Is there a way to work around this?
I already know how to get back to the previous iframe, I did that by adding a submit button with a form action="mypage".
Sir/Ma'am your answers would be of great help. Thank you.

How to hide the "add to cart" button magento

the question seems a litle bit strange, but I wonder if there's an easy solution to hide the add to cart button cause I would like to display a showroom of the products without anything, the add to cart button will only appears after an user event (select a store in a module in that case)
any good tricks to realize that ?
For now I'm thinking a session boolean variable set if the user has check which store he'll be linked to, perhaps there's something better ?
Thx
I am intrigued now as to how this is going to look! As mentioned earlier you can have your store selection stored as a cookie to give some persistence, in that way the site visitor can think and reflect about a purchase and not go through hoops next time they sign in.
If the cookie is not present you could put this in the end of your template to hide the buttons:
if(getCookie('yourstorecookie')==NULL) $$('.add-to-cart').setStyle({display:'none'});

Categories