which ends up talking about the colour of the article button. I have noticed that the article button doesn’t change style/colour if the user is logged and if the article has been purchased.
Apparently the problem is fixed but I couldn’t find any solution online.
I found a solution for this problem, I have seen that it haven’t been fixed in the latest OJS version too…
I run a javascript file that checks the HTML response of the article buttons and eventually removed the css class that makes the button red.
I run a javascipt file that check if the HTML response of the button url is 200 (in case it doesn’t redirect to paypal) and delete the css class ‘restricted’ from the button, if the HTML response of the button url is 203 no actions are required:
// change the style of the PDF button in article pages
$( document ).ready(function() {
$('.obj_galley_link').each(function(){
var currentButton = $(this);
var currentUrl = $(this).attr('href');
$.ajax({
url : currentUrl,
type : 'post'
}).done(function(data, statusText, xhr){
var currentStatus = xhr.status; //200
if(currentStatus === 200){
currentButton.removeClass('restricted');
}
});
});
});
Obviously the script works only if paypal plugin is installed and paypal credential are set.
@marcello8080, your JS-based solution is ingenious, but does involve a few more requests than this one does – if you’re able to confirm that this solution works for you, I’ll get it committed for the next release!
Regards,
Alec Smecher
Public Knowledge Project Team
This Jquery solution reads the HTML status of PDF button url, if the URL takes to paypal it will return 203, if the URL return 200 (it will take to an article view because the article has been already bought ).
So yes it works for me but I have the possibility to test it in a limited number of journal (60 journals in total) and in a single OJS installation.
@ asmecher, I can confirm that this patch does not work in OJS 3.1.2 - in fact, it breaks the page (not the site) you’re trying to change style of (to show the unlocked status).
The above JS makes no difference, but that’s perhaps because we are on manual payments and, according to that code’s author, it’s not meant to work unless PayPal is enabled and works.