I have a problem when I select cost on delivery as shipment method: the paypal button doesn't disappear, so the user could pay twice and this is a undesirable behaviour.
I've attached an image to clarify my problem because I'm searching the web but I don't find the solution.
Thanks
A good way how to do this is through jQuery. Put inside the of your document the following
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
Then find the file where the checkout page is setup and enter the following:
$(document).ready(function() {
if ($('input[name=your_radio_name]:checked').val() == "the value when the element should be hidden") {
$('#id_of_the_element_that_should_be_hidden').hide();
});
});
Related
A client is asking to allow users to register during checkout. The problem is there are some logic about memberships so registering can alter the final price and I can't use the standard Woocommerce way.
So i wrote a couple of validations. First i check if everything is in order, if it is a second validation actually creates the customer account, set all meta fields, login the customer.
Now what I need is to fully realod the checkout page and output a notice telling the customer to press the checkout button again.
I'm using woocommerce_after_checkout_validation but I can't make it work.
I tried a wp_redirect and outputting an ugly in the error notice.
Any ideas on how to do this?
I ended up using Javascript hooks to fire an event after the validation. The error checking is pretty bad, in my case it works but it should be more general.
var error_text = jQuery(".woocommerce-error").find("li").first().text();
if (
error_text.trim() ==
"register_success"
) {
window.setTimeout(function () {
location.reload();
}, 1500);
}
});
I have a 'Create Post' button in which a user can use to submit a post. I only want the user to be able to create one post at a time. So the user would have to remove the first post to create another, or they would have to wait for that post to be removed by someone else - which is perfectly acceptable.
Also, I want the button to be disabled when there is already a live post of theirs.
So, basically, what's the best way to attach the state of the button to the state of the post, so that as soon as the post is removed, the button is then enabled.
Thanks.
Fortunately, spacebars makes this really easy to do. Have a look at the "Smarter Attributes" section of this post.
Here is an example:
<template name="post">
<button disabled={{isDisabled}}>Create Post</button>
</template>
Template.post.isDisabled = function () {
return Posts.findOne();
};
In this case the button will be disabled if any posts were found, but you can easily modify that to your specific requirements.
I'm trying to get Google Analytics working on my blog, but the events are failing to show up in my account.
Part of the issue is that I'm using the new async code, but most of the documentation relates to the older synchronous version. I've read a bunch of SO and blog posts but can't quite see what I'm doing wrong.
One mentions that you have to "activate" event tracking in your site's profile, but I can't find where I might do that.
I originally put my Google Analytics code in an external file called ga.events.js, which is still linked from my site. I attached the events from a jQuery loaded event:
$(function () {
$('.rss').click(function() {
trackEvent("engagement", "rss subscribe", "rss subscription link clicks");
});
function trackEvent(category, action, label) {
_gaq.push(['_trackEvent', category, action, label]);
}
});
But I found a post that said you can't link in an external file for Google Analytics, so I also tried the old fashioned onclick approach:
email list
I put the _target="blank" attribute in case the request wasn't completing before the user navigated away from the page.
Executing the code in the Chrome console on my site returns a 0, when I was expecting a boolean value:
_gaq.push(['_trackEvent', 'Engagement', 'click', 'RSS subscription link'])
I've waited 24 hours after each of these tests to see if the event tracking wasn't real time.
What else should I try? Any obvious mistakes?
Figured it out. I had onclick instead of onClick with a capital C. Wait, JavaScript is a case sensitive language? Who knew?
I also had the syntax of the GA call incorrect.
Here's what my working code looks like:
email list
And here's a version that works using jQuery to attach the click handlers:
$(function () {
$('.rss').click(function() {
trackEvent('Engagement', 'Sidebar link click', 'RSS feed subscription');
});
function trackEvent(category, action, label) {
_gaq.push(['_trackEvent', category, action, label,, false]);
}
});
I have an application on facebook and i have the facebook comment box on it. If someone makes a comment using the comment box, is there a way to notify person that a post has been made on their app
I have the following code
<script src="https://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:comments xid="test" canpost="true" candelete="false" href="<%= link %>" num_posts="10" width="500" send_notification_uid="<%= fbUserId %>" notify="true" publish_feed="true"></fb:comments>
The href - link is a dynamic link depending on where the post was made. The send_notification_uid - user_Id is also dynamic and it retrieves the user id of the person that owns the page.
Any help would be great. It all works apart from the send notification
I believe using the javascript SDK you can subscribe to the comment.create event. Then provided you have the necessary permissions for the uid in question, you could then send them a notification I believe. I haven't tested this but you need to look at the FB.event.subscribe code
https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
There's some more information on a post here
http://facebook.stackoverflow.com/questions/6146925/fb-event-subscribecomment-create-doesnt-work
Further to this you can test things out on the js skd tool
https://developers.facebook.com/tools/console/
and some sample code
<h1>Defaults</h1>
<fb:comments href="http://www.fbrell.com/"></fb:comments>
<script>
FB.Event.subscribe('comments.add', function(resp) {
console.log('Comment was added' + resp);
});
</script>
I don't know if the specs changed, but the current answer doesn't work anymore, the new way is now this :
FB.Event.subscribe('comment.create', function() {
console.log('Comment was added');
console.log(arguments);
});
comment.create , as explained here : https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v2.0#comments-example
I am looking for some clues on where to add Google Analytics Event Tracking to a page that has AnythingSlider installed. I have a slider that does not autoscroll and you have to click the navigation buttons for the slides to move. I wish to track these clicks. I would also like to track if a visitor clicks on a link within a slide.
I am wishing to use Google's InPage Analytics to track visitor click behavior and workout what items (images & phrases) catch the attention of the visitor in order to make better lead funnels.
I did try the Event tracking guide from Google before posting here, but I was unsure of where to pickup the navigation clicks from the slider.
add this to any a href in your html
onClick="_gaq.push(['_trackEvent', 'Slider','Panelno:x', 'blah']);"
Untested (I'm about to do this myself) but the API suggests to me that I should use the onSlideComplete callback, e.g. (assuming you've set up the names of your panels in an array called pages).
onSlideComplete : function(foo) {
_gaq.push(['_trackEvent', 'Slider','Panelno:'+slider.currentPage, pages[index - 1]]);
}
EDIT: Be careful with onSlideComplete, it seems to fire off too often. Set a var to tell it not to refire, and reset the var with onSlideBegin.
onSlideBegin : function(e, slider) {
refire = 1;
},
onSlideComplete : function(slider) {
if (refire) {
_gaq.push(['_trackEvent', 'Slider','Panelno:'+slider.currentPage, pages[slider.currentPage - 1]]);
refire=0;
}
}