[OJS 3.1.1] Article button doesn't change style in case of login

Hi all

I was following this conversation:

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.

Can you please advice?

Thanks a lot

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.

Do you guys want me to share the solution?

Thanks

Hi @marcello8080,

Yes, please share what you’ve changed!

Thanks,
Alec Smecher
Public Knowledge Project Team

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.

Hope this can help

Hi all,

Please try out the change at Article access status does not change when individual article or issue purchased · Issue #4924 · pkp/pkp-lib · GitHub and see if that works for you.

@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

Hi @asmecher

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.

Thanks

Hi @marcello8080,

I was hoping you’d be able to try out the patch in the git issue linked above, in place of your JS-based solution.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @ marcello8080, would you know how to implement this when manual payments are used instead of PayPal?

@ 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.

Yes, I am aware that the JS code works only if Paypal plugin is enabled and set properly.

Can you please specify I URL of article with manual payments? I will have a look at it.