I have upgraded the Magento version to 2.3.7. After that, I have a strange issue on the checkout page that when it calls ajax function the URL is been wrongly generated. Previously it was like
/rest/default/V1/guest-carts/AC72N37Vmo3uGMIXEVQfIDt1ubuZLJws/estimate-shipping-methods
but after upgrading Magento version now it's
/checkout/undefinedrest/default/V1/guest-carts/AC72N37Vmo3uGMIXEVQfIDt1ubuZLJws/estimate-shipping-methods
Not sure from where this undefined gets added within the url ??
Research Notes: -
The secure & unsecure base url are correctly setup. I checked it again
Also i navigated to the file from where this ajax call is generated , the file is
vendor/magento/module-checkout/view/frontend/web/js/model/shipping-rate-processor/new-address.js
Here the storage.post is from the ajax call is generated and it has
serviceurl & payload as arguments.
in getRates function - if we console.log "serviceUrl" then it shows the below url
rest/default/V1/guest-carts/FsS4QvllSq1vpuxZuC8ycQa0VRMOcQCy/estimate-shipping-methods
which seem to be correct, storage.post() function takes this as an argument and ajax request is called which then gets into the .fail() function
so what i think is that the problem is where the front part of the url gets added to it for making the ajax call that is
http://sitename.local/checkout/undefined ---> and here somehow the undefined gets added which breaks the whole url
The same issue is encountered by other users also but no solution is available yet.
https://magento.stackexchange.com/questions/256273/undefined-rest-api-checkout-cart
https://community.magento.com/t5/Magento-2-x-Programming/Magento2-Wrong-base-url-on-ajax-call/td-p/435435
Can anyone help me out from this?
I am answering my own question as i was able to fix the issue myself.
I am not sure if this solution would be a general solution to everyone facing similar issue but as in my case it helped me fix the issue , so it may guide others facing similar issue , if the solution isn`t 100% accurate in their scenario.
So in my project i had a file as
app/design/frontend/Birdbrain/default/Magento_Theme/templates/page/js/require_js.phtml
which had the following code inside it
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<script>
var require = {
"baseUrl": "<?php /* #escapeNotVerified */ echo $block->getViewFileUrl('/') ?>"
};
</script>
After removing this file from the source, the issue explained in the question above was fixed and no other issues arised by removing it.
Thoughts :-
As i checked in my version control system , i found that this file was added in 2017 and since then no changes were done in it, so after upgrading the magento version to 2.3.x , it somehow conflicted with some latest code and was no longer meaningful and so removing it fixed the issue , atleast for me.
Related
My website had a older version of wordpress. Recently I upgraded it to the latest version. After that my php code what I write in the editor is keep getting disabled.
The old page which has php code in ti still works. Although in the editor the php codes are disabled. But if I try to save that it stops working. So i cannot update those page. And also I cannot create new page with php code in it
Exec-PHP plugin is installed.
If I write
<?php echo $c; ?>
It converts into
<!--?php echo $c; ?-->
How to fix that
attached image for better understanding.
Another way, which I don't quite recommend, is to follow this direction:
https://wordpress.org/support/topic/exec-php-to-work-in-php-7-needs-this/
This is basically updating the actual plugin, which will surely be overwritten by their next update.
This plugin requires a number of changes to work with php 7.
In exec-php.php
$GLOBALS[‘g_execphp_manager’] =& new ExecPhp_Manager();
must be changed to
$GLOBALS[‘g_execphp_manager’] = new ExecPhp_Manager();
In includes/manager.php from line 36
change each =& to =
In includes/admin.php lines 53,56,57,63,64,79 change =& to =
In includes/cache.php line 22,39 change =& to =
In includes/ajax.php line 64 change =& to =
I don't know about the plugin you use for this. However, I use xyzscripts for the same cause. It creates short-codes for me to use.
Here is an example:
Create your PHP code and get a Tracking Name.
You will then get your short-code as below, note the Tracking Name.
I personally think this is the best way as it allows re-usability and centralized location to update all your scripts.
XYZ WP PHP Code Download and Documentation
Thank you all for responding.
Apparently I find the solution by installing the Classic Editor plugin
https://en-gb.wordpress.org/plugins/classic-editor/
It prevents disabling the php code.
If you are facing similar problem you can try this one
The one page checkout for my store doesn't complete. On the final step (order review), I get this error as a return from the Ajax call to checkout/onepage/saveOrder:
Server was unable to read request. ---> There is an error in the XML document. ---> Input string was not in a correct format.{"success":true,"error":false}
After logging every variable and array I could find in the saveOrderAction method of OnepageController.php, it looks like the redirectUrl from this line is returning nothing:
$redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
I haven't found anyone else having this exact problem, and I have a feeling this is being caused by some admin setting that I missed while setting my store up. The production site works fine and I've copied every file onto my local server. Any ideas?
I'm following the CKFinder 2 to 3 upgrade guide and it's not making much sense. In CKFinder 2, the PHP code provided could be used to generate the JS snippet with appropriate config and params, like this:
require_once 'ckfinder/core/ckfinder_php5.php';
$finder = new CKFinder() ;
$finder->SelectFunction = 'ShowFileInfo' ;
$finder->DisableThumbnailSelection = true;
$finder->RememberLastFolder = true;
$finder->Id = $name;
$finder->StartupFolderExpanded = true;
$finder->Width = $width;
$finder->Height = $height;
echo $finder->CreateHtml();
This code picks up the config and incorporates it into the generated JS.
In 3 this seems to have disappeared entirely - the upgrade guide describes the changes needed in config.php, but there is no indication of how this is ever used since there is no other PHP involved, and it says
It is no longer possible to enable CKFinder on a page from the PHP level
All that is shown is how to create the JS snippet, which does not contain any config, and so will use incorrect settings. There is no indication of how the config properties set in config.php ever get to the JS code - as far as I can see there is no connection at all and no mention of any other PHP files, even though some are provided but not documented.
This makes no sense - PHP can quite happily generate HTML and JS that is run on the page, which is all the old CreateHTML function did. I don't understand why there is no mention of this mechanism since it was how we were supposed to use CKFinder previously - it's as if the migration guide is for some unrelated package!
If I update the config file and use the default JS widget code as suggested, it breaks the page completely, altering the MIME output type so it does not get rendered as HTML and appends this error:
{"error":{"number":10,"message":"Invalid command."}}
The docs cover various fine details of what PHP config settings mean, but nowhere that I've found says how it's ever loaded, triggered or associated with the JS. How is this supposed to work?
Indeed the CKFinder 3 documentation was lacking some important information. We're gradually adding new articles there. Based on topics you mentioned I just added:
Explanation how PHP code that worked for CKFinder 2 can be refactored to plain JavaScript in CKFinder 3. Should look familiar ;)
A table with Configuration Options Migration - JavaScript Settings which should help you with discovering again options like rememberLastFolder
Forgive me for my English
I am new in PHP. And I'm building a site using Silverstripe and trying to configure Vimeo-Service-module. I'd follow the steps from this link
https://github.com/r0nn1ef/Silverstripe-Vimeo-Service-module
I did everything that mentions in the article. And created a page in admin panel of VimeoGallery page type and set the parameters on Videos tab to grab the videos for display.
After created page, I visited my and clicked on video menu but then all I see is no videos returned. It is showing blank page and no any error messages.
Is that I've done anything wrong. Please guide me...
Thanks in advance.
OK, I think I see the issue here. You are calling VimeoService::setAPIKey() however accessing the method like that is deprecated in the new version (the 2.0 branch - I was incorrect in my comment when I mentioned master) of the module.
The module instead uses the Site Config in the CMS to set the API key and a few other settings.
Now just remove VimeoService::setAPIKey() from your _config.php file, run /dev/build and set the API key through the CMS.
EDIT
On line 142 of VimeoGalleryPage.php, there is a function called flushCache. Replace the code in that function with the following:
public function flushCache($persistent = true) {
parent::flushCache($persistent);
unset($this->_cachedVideos);
}
Basically, the code in the 2.0 branch for this function does not correctly extend the same named function in SiteTree.
This question is somewhat related to my previous question (not necessary to go through it)
link text
, although this one is more of an Ajax problem.
I tested my page in firebug and I am getting the following error
Event.Observe is not a function
Event.observe('form908983160', 'submit', function(event) { new Ajax.Updater('comments','/blog/posts/comments/add', {asynchronous:true, evalScripts:true, parameters:Form.serialize('form908983160'), requestHeaders:['X-Update', 'comments']}) }, false);
I am using the prototype framework for developing my cake php application.
How should I fix this problem?
Guys, I really need your help in this one. I am really stuck at this one. [:(]
prototype.js has to be :
loaded in the page (verify it's not in 404, for instance)
loaded in the page before the execution of your script
Which generally means you need to include prototype.js first, and, only after that, you can include your scripts.
As a sidenote : you are not using any other JS Framework in that page, of course...
Remember that any Event.observers need to be used in global
Event.observe(window,'loaded',f);
// or
Event.observe(document,'dom:loaded',f)
otherwise they will not work.
For me it looks like there's problem with linking to Prototype. Open firebug and try to see the contents of your script files - if you see html, that means something went terribly wrong :-)