I'm using a dating cms and I'm currently getting the following error message:
array(4) { ["type"]=> int(8) ["message"]=> string(40) "Undefined variable: HEADER_SINGLE_COLUMN" ["file"]=> string(44) "/home/......../public_html/index.php" ["line"]=> int(7812) }
Below is the code:
if($HEADER_SINGLE_COLUMN!="yes"){
if($page == 'articles'){
require_once ( "inc/templates/layout/recent_articles.php" );
}
else if($page != "register" && $page != "mgal"){
if($page != "wld" && $page != "compatibilityquiz"){
require_once ( "inc/templates/layout/quick_search.php" );
}
}
}
I am not a coder, thank you for your indulgence.
Do you have a solution for me.
Thank you for your help.
Cordially
Christophe
Related
I have two different shipping method on my WooCommerce site COD & local pickup, I want to redirect on two different thank you page depending on which shipping method the buyer choose. I tried this but its showing an error after purchase
add_action( 'template_redirect', 'woo_custom_redirect_after_purchase' );
function woo_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && !empty( $wp->query_vars['order-received'] )) {
if( $order->has_shipping_method('flat_rate:21') ){
wp_redirect( 'mysite.com/thank-you-1/' );
exit;
}
elseif( $order->has_shipping_method('local_pickup:24') ) {
wp_redirect( 'mysite.com/thank-you-2/' );
exit;
}
}
}
You can use woocommerce_thankyou
add_action( 'woocommerce_thankyou', 'woo_custom_redirect_after_purchase');
function woo_custom_redirect_after_purchase( $order_id ){
$order = wc_get_order( $order_id );
if( $order->has_shipping_method('flat_rate:21') ){
wp_redirect( 'mysite.com/thank-you-1/' );
exit;
}elseif( $order->has_shipping_method('local_pickup:24') ) {
wp_redirect( 'mysite.com/thank-you-2/' );
exit;
}
}
I'd like to make billing company and shipping company not required in WooCommerce. For some reason the code I am using works for EVERYTHING except for the company part. It turns out a third party plugin is making the company name required, here is the full code of that plugin:
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once('legacy_pakkelabels_shipping_main.php');
/**
* #class Pakkelabels_Shipping_GLS_Business_Legacy
* #version 0.1.0
* #author Magnus Vejlø - Pakkelabels
*/
class Legacy_Pakkelabels_Shipping_GLS_Business extends Legacy_Pakkelabels_Shipping_Main
{
public function __construct($instance_id = 0)
{
$this->id = 'legacy_pakkelabels_shipping_gls_business';
$this->instance_id = absint($instance_id);
$this->method_title = __('GLS Business ', 'woocommerce-pakkelabels');
$this->method_description = __('Adds the option to ship with the GLS business to the checkout', 'woocommerce-pakkelabels');
$this->init();
}
/* add the diffrent actions */
function addActions()
{
//adds the shipping method to the WooCommerce
add_filter('woocommerce_shipping_methods', array($this, 'register_shipping_method'));
add_action('woocommerce_after_shipping_rate', array($this, 'pakkelabels_shipping_gls_business_show_below_shipping'));
add_action('woocommerce_checkout_process', array($this, 'pakkelabels_shipping_gls_business_field_process'));
}
function addFilters()
{
}
function pakkelabels_shipping_gls_business_field_process() {
global $woocommerce;
$choosen_shipping_method1 = preg_replace('/\d/', '', $woocommerce->session->chosen_shipping_methods[0] );
$choosen_shipping_method2 = preg_replace('/\d/', '', $woocommerce->session->chosen_shipping_methods );
if((isset($_POST['ship_to_different_address']) && ($_POST['shipping_company'] == '' || !isset($_POST['shipping_company']))) && ($choosen_shipping_method1 == "legacy_pakkelabels_shipping_gls_business" || $choosen_shipping_method2 == "legacy_pakkelabels_shipping_gls_business")){
if ( version_compare( $woocommerce->version, '2.1', '<' ) ) {
$woocommerce->add_error(__('Please fill out the Shipping company', 'woocommerce-pakkelabels'));
} else {
wc_add_notice( __('Please fill out the Shipping company', 'woocommerce-pakkelabels') , 'error');
}
}
if((!isset($_POST['ship_to_different_address']) && ($_POST['billing_company'] == '' || !isset($_POST['billing_company']))) && ($choosen_shipping_method1 == "legacy_pakkelabels_shipping_gls_business" || $choosen_shipping_method2 == "legacy_pakkelabels_shipping_gls_business")){
if ( version_compare( $woocommerce->version, '2.1', '<' ) ) {
$woocommerce->add_error(__('Please fill out the billing company', 'woocommerce-pakkelabels'));
} else {
wc_add_notice( __('Please fill out the billing company', 'woocommerce-pakkelabels') , 'error');
}
}
}
function pakkelabels_shipping_gls_business_show_below_shipping($rate){
global $woocommerce;
global $woocommerce;
$choosen_shipping_method1 = preg_replace('/\d/', '', $woocommerce->session->chosen_shipping_methods[0] );
$choosen_shipping_method2 = preg_replace('/\d/', '', $woocommerce->session->chosen_shipping_methods );
if($choosen_shipping_method1 == "legacy_pakkelabels_shipping_gls_business" || $choosen_shipping_method2 == "legacy_pakkelabels_shipping_gls_business"){
if($rate->method_id == 'legacy_pakkelabels_shipping_gls_business'){
echo '<div class="gls_shipping_method_text shipping_company_required">' . __('The company name is required.', 'woocommerce-pakkelabels').'</div>';
}
}
}
/* Register the shipping method in WooCommerce*/
function register_shipping_method($methods)
{
$methods['legacy_pakkelabels_shipping_gls_business'] = 'Legacy_Pakkelabels_Shipping_GLS_Business';
return $methods;
}
}
$pakkelabels_GLS_Business_Legacy = new Legacy_Pakkelabels_Shipping_GLS_Business();
$pakkelabels_GLS_Business_Legacy->mainAddActions();
$pakkelabels_GLS_Business_Legacy->addActions();
$pakkelabels_GLS_Business_Legacy->addFilters();
The plugin used is a delivery plugin, and since we're delivering to companies it requires a company name. However, since we are a B2B store we already have these company names registered and we do not want them nor need them in the checkout. So we have hidden the company name field in WooCommerce, but no matter what code we write we cannot make it not require it to be filled out.
Try the filter woocommerce_default_address_fields instead.
function modify_woocommerce_default_address_fields( $fields ) {
$fields['company']['required'] = false;
return $fields;
}
add_filter( 'woocommerce_default_address_fields', 'modify_woocommerce_default_address_fields', 100, 1 );
It states this in the documentation that there are specific fields that must be manipulated through this filter.
country
first_name
last_name
company
address_1
address_2
city
state
postcode
We can use a filter to remove the notice before it is added to the array specific just to that error message.
function modify_woocommerce_notices( $message ) {
if( stripos( $message, 'Please fill out the billing company' ) !== false ) {
return '';
}
}
add_filter( 'woocommerce_add_error', 'modify_woocommerce_notices' );
I haven't tested that code but that's the general idea of how you would suppress the error and prevent the required field for the billing company.
I'm missing a column in my exchangeArray. It is the column with the filename, here a snippet of my controller add action:
if ($form->isValid()) {
$data = $form->getData();
// Upload path
$location = "public/files/";
// A bit validation of uploaded file
$allowedExtension = array('xls', 'xlsx');
$extension = explode('.', $data['DCL_Path']['name']);
$extension = end($extension);
$import['DCL_Path']=$data['DCL_Path']['name'];
//$fileName = time() . '.' . $extension;
$fileName = $data['DCL_Path']['name'];
// Check if everything is OK!
//echo $fileName;
if (0 === $data['DCL_Path']['error'] && in_array($extension, $allowedExtension)) {
move_uploaded_file($data['DCL_Path']['tmp_name'], $location . $fileName);
} else {
echo 'Something went wrong!';
}
//$namen = explode(",", $import ); //Konvertierung des Strings in ein Array
//echo "<pre>"; var_dump($namen); echo "</pre>"; //Formartierte Ausgabe des Arrays
$this->table->saveImport($import);
Everything will be saved, but DCL_path is missing.
Here my exchangearray also:
public function exchangeArray(array $data)
{
$this->DCLID= !empty($data['DCLID']) ? $data['DCLID'] : null;
$this->UnitID= !empty($data['UnitID']) ? $data['UnitID'] : null;
$this->DCL_Path= !empty($data['DCL_Path']) ? $data['DCL_Path'] : null;
$this->Importdate= !empty($data['Importdate']) ? $data['Importdate'] : null;
$this->Importuser= !empty($data['Importuser']) ? $data['Importuser'] : null;
$this->Importok= !empty($data['Importok']) ? $data['Importok'] : null;
$this->DCL_Type= !empty($data['DCL_Type']) ? $data['DCL_Type'] : null;
$this->Changed_per_User= !empty($data['Changed_per_User']) ? $data['Changed_per_User'] : null;
$this->Description_Changes= !empty($data['Description_Changes']) ? $data['Description_Changes'] : null;
}
I added this statement: $import['DCL_Path']=$data['DCL_Path']['name']; to force it, but it didn't help. So my question would be how to add data in datafields of my exchangeArray.
EDIT1: Here is the start off my addAction.
$import = new Import(); //Neue Instanz von Import
$form->setInputFilter($import->getInputFilter()); //Filter an Form binden
$form->setData($request->getPost()); //Daten abholen
//echo $form->isValid();
if (! $form->isValid()) {
return ['form' => $form]; //Wenn die Daten nicht valide sind
// return $this->redirect()->toRoute('import'); //Routing
// Zend_Debug::dump("nicht valide");
//echo "nicht valide";
}
else{ //aus Tableadapter
$import->exchangeArray($form->getData());
// echo "valide";
//echo $import["DCL_Path"];
// Merge data thus
$data = array_merge_recursive(
$this->getRequest()->getPost()->toArray(),
$this->getRequest()->getFiles()->toArray()
);
$form->setData($data);
I also find another solution which is working, I post it additional perhaps it might help somebody else. Of course I still would prefer the way via exchangeArray.
$this->table->saveImport($import); //Daten speichern
$letzter = $this->table->getlastImport($fileName);
echo ($letzter->DCLID);
$this->table->updateoneRow($letzter->DCLID, 'DCL_Path', $fileName);
with my app's administrator acount on facebook my app work normally, but with other app I get error: Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. What's wrong here? I tried many ways using different guides but does not return true results .Help me, please if you can, Thank you very much.
My code here :
//$return_url = loginFacebook;
$this->load->library('facebook', $this->app_config);
parse_str($_SERVER['QUERY_STRING'], $_GET);
if (isset($_GET['code'])) {
if (isset($_GET['code']) && !isset($_GET['error'])) {
$user = $this->facebook->getUser();
if($user){
try{
$fb_user = $this->facebook->api('/me?fields=email,username,name,picture');
//print_r('<pre>');print_r($fb_user);die;
if (!$fb_user) {
show_error('invalid access_token');
}
if(!isset($fb_user['email'])) {
show_error('invalid facebook account');
}
// do somthing here
$this->load->view('login_success',$array);
}
}catch (FacebookApiException $e) {
echo $e->getMessage();
}
} else {
echo "Could not log in with Facebook";
}
} else if ($_GET['error']) {
show_error('user denied!!!');
}
} else {
$log = array(
'scope' => $this->scope,
'redirect_uri' => $return_url
);
if(strlen(store()) > 1) $log['display'] = 'popup';
else $log['display'] = 'wap';
$loginUrl = $this->facebook->getLoginUrl($log);
header("Location: $loginUrl");
}
How can i upload a file? Stackoverflow i cant page codes so please check this link: http://pastebin.org/386639
Thanks in advance
LATER:
Later i updated this as following, because ZF is not friendly, they keep still everything top secret! :P
public static function mvUploadFile()
{
//
// $_GET/_POST/FILE what ever
//
$fname = basename( $_FILES['attachment']['name']);
$_fname = strtolower (end(explode('.',$fname) ) );
Zend_Debug::dump( $_FILES );
//
// Filter the file
//
switch($_fname)
{
case ($_fname == 'jpg' ||
$_fname == 'jpeg' ||
$_fname == 'gif' ||
$_fname == 'bmp' ||
$_fname == 'png' ||
$_fname == 'html' ||
$_fname == 'pdf' ||
$_fname == 'doc' ||
$_fname == 'docx' ||
$_fname == 'xls'
):
$target_path = APPLICATION_PATH . "/../public/files/textual_translation_attachment/";
//chmod("../up" , 0777);
$target_path = $target_path . basename( $_FILES['attachment']['name']);
if(move_uploaded_file($_FILES['attachment']['tmp_name'], $target_path)) {
//echo "The file ". basename( $_FILES['file']['name']). " has been uploaded";
//$_sql = "insert into a (huis,image) values ('$_app','$_file')";
// send the file name only .....
//echo $fname ;
}else{
//echo "error ";
}
break;
}
return $fname;
}
If you
Zend_Debug::dump($_FILES);
Do you see your file?
If you are using jQuery, you may want to try Uploadify. This can be done using the
Zend Framework Uploadify Extension
http://gondo.webdesigners.sk/zend-framework-uploadify-extension/