Adding stripe button to the pricing table - javascript

I'm using marketers delight 3 wp child theme, their pricing tables. I want to replace the standard "order now" button with the stripe script button. I can only put URL's in that field. What can I do in this case?
Here is the stripe script itself:
<form action="/charge" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="xxx"
data-image="/square-image.png"
data-name="xxxx"
data-name="Silver Package"
data-label="Buy the Silver Package - $29.99"
data-description="Silver Package ($29.99)"
data-amount="2999">
</script>
</form>
How can I add this button to the pricing table if that Order Now field can be filled only with an URL?

Edit the theme. Open up the template for that specific part, remove or comment the button with php so it does not show up in devtools and place this stripe code.

Might not be the best approach, pick the one you like the most
Try to inject it into the href field like this:
$injection= ' ">'.$stripe_button_code.' <a style="display:none';
<a href="<?=$injection;?>"> title
Try to put an onclick action on the link that clicks on the stripe
button somewhere on the page
Same as 2 but if you can't use onclick maybe you can use
javascript:function(){ } for the href
Edit the theme file and do it without work arounds [Reccomended]

Related

When a link is clicked, I want to show a value/price on the next page

I have this code on page 1. All a tags have the same link. If the user clicks on one link, the next page 2 is loaded. I want to display the price of that id specific to that link to show on page 2.
example: If the user clicks a link with id="saloon_price", the price on page 2 should appear Saloon: £50.
If the user clicks the link with id="mpv_price", the price on page 2 should appear MPV: £70.
Please help me to achieve this on page 2.
I am very new to coding. And using Javascript. Kindly help me with a simpler solution. Thanks
<a id="saloon_price" href="/quotes/details"> Saloon: £50</a>
<a id="estate_price" href="/quotes/details">Estate: £60</a>
<a id="mpv_price" href="/quotes/details">MPV: £70</a>
In the web, we pass values mainly using the URL, and read them again in the loaded page.
<a id="saloon_price" href="/quotes/details?label=Saloon&value=£50"> Saloon: £50</a>
<a id="estate_price" href="/quotes/details?label=Estate&value=£60">Estate: £60</a>
<a id="mpv_price" href="/quotes/details?label=MPV&value=£70">MPV: £70</a>
And read this post for more details:
How to get the value from the GET parameters?
You will propably need to use PHP or other server-side languages. You can do this easily with forms. But you will need to run this on some kind of server.
This will echo (type to document) the value of value attribute on the button...
index.php:
<form action="/quotes/details.php" method="post">
<button type="submit" name="price" value="£50" id="saloon_price"> Saloon: £50 </button>
...other buttons...
</form>
/quotes/details.php:
...
<?php
$price = $_POST["price"];
echo "MPV: " . $price;
?>
...
You can use method="get" and $_GET["price"] if you want to see these values in url.

Removing a Product using button in laravel route link

I created a sample products page using laravel framework,where I added a Remove button to remove that particular product onclick. below is the laravel route code added to the button
<button onclick= "window.location= '{{ route('customer.wishlist.remove', $item->id) }}'" > Remove </button>
here the item id is automatically generated from database which can also be seen by inspecting the remove button code.
on clicking the Remove button the product is getting removed. but when i run the route link separately in the browser then also the product getting removed because the same location link is given to button also.
I want this operation work only on Remove button click. if i entered the route url directly it should'nt. How can i resist that.
please help me on this
thank you
First of all you're using get method so it can be directly accessible to the browser.
Now if you don't want to allow a user to directly access that URL then you need to make the request as POST
<button onclick="event.preventDefault(); document.getElementById('delete').submit();">Remove </button >
<form id="delete" action="{{ route('customer.wishlist.remove', $item->id) }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
Make your route as post

HTML form split to two different submissions

I performed a shopping cart integrated to my website and now I am trying to use only one form to be filled by customer (personal information) but I am facing a issue because I would like to use two different submit button depending on the payment platform chosen by customer. Does anybody know a simple solution for that? I appreciate in advanced.
you have to pass name attribute with different value of name attribute in button tags like that --
<button type="submit" name="button1">Button 1</button>
<button type="submit" name="button2">Button 2</button>
In php code --
<?php
if(isset($_POST['button1]))
{
// here we will add code of button 1
}
if(isset($_POST['button2]))
{
// here we will add code of button 2
}
?>
please try this .....
Use multi step form pattern.You can find huge of examples by searching on google.

Switching between pages on selecting the radio button without redirect or submit

i am a bee on PHP and i want a solution to switch between two pages on when selecting a radio button with out submit the page or redirecting the page ?
Which one is the more appropriate way
javascript or
php ?
Please help me with a suitable example.Thank you.
Trythis:
you can simple call a link , if you don't have a container in that page to load the new page when radio button is pressed .
You have no option that link the radio with page link ,
But , if you want to load the content of that page inside you php page without redirecting ot post then ur ultimate friend is JQuery and Ajax.
You can handle this with Jquery / Javascript in better way:
Try this:
$("#example").change(function(){
window.location="http://www.example.com/";
});
$("#wiki").change(function(){
window.location="http://www.wikipedia.org/";
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="radio" id="example"> Example Side <br/>
<input type="radio" id="wiki"> Wikipedia Side

How to call LinkedIn authorize javascript from button

This line of sample code from LinkedIn API works perfectly.
<script type="IN/Login" data-onAuth="loadData"></script>
but it runs automatically as the web page loads. I'd like to invoke this script using a button or link on a webpage. The idea being that the webpage loads and waits until the user is ready to authenticate.
Ideally I would like the LinkedIn Login image to appear, and wait, until clicked.
Thanks.
Based on your comment, it looks like you only want to display the SignIn plugin if the user has manually clicked a button/element on the page. Something like this, using jQuery, should work:
On your page, you have a button:
<div id="buttonControl">
<input type="button" id="showLinkedIn" value="Show LinkedIn" onclick="showLinkedIn();" />
</div>
<div id="buttonContent" style="display: none;"></div>
In a script block in the <head> of the page, you have the showLinkedIn() onclick function:
function showLinkedIn() {
// insert the SignIn plugin
$('#buttonContent').html('<script type="IN/Login" data-onauth="loadData"><\/script>');
// tell the LinkedIn JavaScript code to re-parse the element containing the SignIn plugin
IN.parse($('#buttonContent')[0]);
// hide button trigger, if needed
$('#buttonControl').hide();
// show the LinkedIn control
$('#buttonContent').show();
}
$('#buttonControl').click(function(){
$('#buttonContent').html('<script type="IN/Login" data-onauth="loadData"></script>');
$('#buttonControl,#buttonContent').toggle();
IN.User.authorize(loadData);
});
slightly different as the 'IN.parse($('#buttonContent')[0]);' does not seem to work...
tested 'IN.User.authorize(loadData)' and it works well! Got it from: http://developer.linkedin.com/documents/inauth-inevent-and-inui
You need to clear the cookies from the following method like
IN.User.logout(callbackFunction, callbackScope);
You need to call this function on that button from which you want to log out.
Example using jquery:
$('#demo') .click(function()
{
IN.User.logout(console.log("logged out..."));
});

Categories