Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9067121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:52:27+00:00 2026-06-16T16:52:27+00:00

Here is the standard code I am using for getting cart items and their

  • 0

Here is the standard code I am using for getting cart items and their attributes which works only when the customer is not logged in. As soon as I log in using my account this script stops working and does not return the items in the cart. Also the cart items count is also 0. But as soon as I close the browser(session ends..) and the script returns the cartitems correctly! Very strange, I have not been able to find out the cause. Please guide, anyone?

require_once('../app/Mage.php') ;
umask(0);
Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend'));

$session = Mage::getSingleton('checkout/session');
$items = $session->getQuote()->getAllVisibleItems();
foreach ($items as $item) {
//$canProceed=0;
echo $productname = $item->getName();   //HERE IS THE COMPLETE CODE:<?php 
ini_set('display_errors',true);
require_once('../app/Mage.php') ;
Mage::setIsDeveloperMode(true);
umask(0);
Mage::app();


  //Getting buyer's country label

 $bcountry1 =  $_REQUEST['country']; //gets country code

$_countries = Mage::getResourceModel('directory/country_collection')
                                ->loadData()
                                ->toOptionArray(false);

foreach($_countries as $_country){
if ($_country['value']==$bcountry1){$bcountry = $_country['label'];}
}
//Fetching vendor for each product

$config  = Mage::getConfig()->getResourceConnectionConfig("default_setup");

$dbinfo = array("host" => $config->host,
        "user" => $config->username,
        "pass" => $config->password,
        "dbname" => $config->dbname    );

$hostname = $dbinfo["host"];
$user2 = $dbinfo["user"];
$password = $dbinfo["pass"];
$dbname = $dbinfo["dbname"];


$dbhandle = mysql_connect($hostname,$user2,$password) or die("Unable to connect"); 
$selected = mysql_select_db("myart2",$dbhandle);


$Proceed=0;

//Getting all products in the cart
//echo $cart = Mage::getSingleton('checkout/cart')->getItemsCount();
// Secret Sauce - Initializes the Session for the FRONTEND
// Magento uses different sessions for 'frontend' and 'adminhtml'
Mage::getSingleton('core/session', array('name'=>'frontend'));

$session = Mage::getSingleton('checkout/session');
$items = $session->getQuote()->getAllVisibleItems();
foreach ($items as $item) {
//$canProceed=0;
$productname = $item->getName();

$product = Mage::getModel('catalog/product')->loadByAttribute('sku',     $item->getSku(), array('manufacturer'));
    $manufacturer =   $product->getResource()->getAttribute('manufacturer')->getFrontEnd()->getValue($product);


 $qry="select * from vendors WHERE company_name='$manufacturer'";
$result =  mysql_query($qry) or die("Unable to run select query");
  $row = mysql_fetch_array($result) or die("Unable to fetch data");

if( strcasecmp($row['country'],$bcountry)!=0 && $row['ships_abroad']!=1)
{$Proceed=1;$productnames[]=$productname;}
}

if($Proceed==1)
{
echo implode(',',$productnames);
}
else {echo 1; }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:52:28+00:00Added an answer on June 16, 2026 at 4:52 pm

    I’ve tested the following four main permutations, and the code works in a stock CE1.7 instance in all cases:

    • Create guest quote
    • Convert guest quote to customer quote via login
    • Instantiate existing customer quote via login
    • Merge guest quote with customer quote via login

    Adjust the server & app environment params as follows to view & rule out any errors (edit – added complete script; note the closing “}”):

    <?php
    
    error_reporting(E_ALL | E_STRICT);
    ini_set('display_errors',true);
    require_once('../app/Mage.php') ;
    Mage::setIsDeveloperMode(true);
    umask(0);
    Mage::app();
    
    $session = Mage::getSingleton('checkout/session');
    $items = $session->getQuote()->getAllVisibleItems();
    
    foreach ($items as $item) {
        //$canProceed=0;
        echo $productname = $item->getName();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code: /* Scott Landau Robot Lab Assignment 1 */ // Standard
We're using xVal and the standard DataAnnotationsValidationRunner described here to collect validation errors from
Not too sure what's going on here as this doesn't seem like standard practise
I'm trying to convert some VC++ 6 code to a console app using only
I am getting the above error. I am coding in C and using standard
This is pretty standard stuff here, and I cannot understand why it isn't working.
Here is the textbook standard way of describing a 'class' or constructor function in
Here and here it is written how to convert a standard WCF Service to
I've posted the same question here a few days ago( Java reading standard output
We currently have a form with the standard multi-select functionality of here are the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.