Woocommerce filters not doing anything - hook-woocommerce

I have 2 woocommerce filters not doing anything. Can someone tell me if something is wrong with them ?
add_filter('woocommerce_checkout_fields', 'custom_override_checkout_fields');
function custom_override_checkout_fields($fields)
{
$fields['billing']['billing_email']['placeholder'] = 'Courriel ';
return $fields;
}
add_filter( 'woocommerce_countries_inc_tax_or_vat', function () {
return __( '(incl. GST)', 'woocommerce' );
});```
Thanks

Related

I'd like for my streams in RxJS to wait for all items in the stream to complete before moving on, but cant figure out how

I'm using RxJS in combination with Neo4J and NestJS.
Every step needs to be fully completed in order for the next step to be able to process successfully, so ideally i'd like to replicate a Promise.all() for each of the following steps found in the chunk of code below.
Problem is, that tap doesnt seem to allow me to wait for all promises to complete, and I'm really not sure how to achive this.
loadBooks() {
const booksObservable =
this.booksService.getBooksFromAPI();
booksObservable
.pipe(
mergeMap((response) => response.data),
tap((protocol) => {
return from(
this.booksService.find(book.name).then((bookNode) => {
if (!bookNode) {
return from(
this.bookService.create({
name: book.name
}),
);
}
}),
);
}),
groupBy((book) => book.category),
tap((categoryName) => {
return from(
this.bookCategoryService
.find(categoryName.key)
.then((categoryNode) => {
if (!categoryNode) {
return from(
this.bookCategoryService.create({
name: categoryName.key,
}),
);
}
}),
);
}),
mergeMap((group) => group),
tap((book) => {
let bookId: string;
let categoryId: string;
return from(
this.bookService
.find(book.name)
.then(async (bookNode) => {
if (!bookNode) {
throw new NotFoundError(
`Could not find book by name ${book.name}`,
);
}
bookId = bookNode.getId();
await this.bookCategoryService
.find(book.category)
.then(async (categoryNode) => {
if (!categoryNode) {
throw new NotFoundError(
`Could not find category by name ${protocol.category}`,
);
}
categoryId = categoryNode.getId();
await this.bookService.relateToCategory(
bookId,
categoryId,
);
});
}),
);
}),
)
.subscribe(() => {
return 'done';
});
How do i make it so that the operations in the tap fully complete for each and every item in the stream, before moving on tho the next function in the pipe?
Thanks!

Route not loading

I'm having issues with a route in Zend Framework 2. For instance, in module.config.php I have it set up as follows:
'user' => array(
'type' => 'Segment',
'options' => array(
'route' => 'user[/:action][/:store_id]',
'defaults' => array(
'controller' => 'Application\Controller\User',
'action' => 'index',
),
),
),
Now, I have a function in JavaScript that calls the route part [/:store_id] when a image is clicked on.
function viewStore(id) {
if (typeof id !== undefined) {
$.getJSON('/user/store/' + id, function(data) {
document.getElementById('view-store-modal').style.display = 'block';
$.each(data, function(i) {
$('#main-store-name').html(data[i].store_name);
$("#main-store-image").prop('src', data[i].store_image);
$("#main-store-image").addClass("w3-padding").addClass("w3-round");
$('#main-store-image').attr('style', 'width: 400px; height: 200px; display: block');
$('#main-store-description').html("Store Description: " + data[i].store_description);
$('#main-store-category').html("Store Category: " + data[i].store_category);
if (data[i].number_of_items === null) {
$('#main-store-items').html("No items exist for this store yet, go add some!");
} else {
$('#main-store-items').html("Number Of Items: " + data[i].number_of_items);
}
});
});
}
}
Here is the controller code:
public function storeAction()
{
$layout = $this->layout();
$layout->setTerminal(true);
$view_model = new ViewModel();
$view_model->setTerminal(true);
$id = $this->params()->fromRoute('store_id');
if ($id !== null) {
try {
echo json_encode($this->getUserService()->getStoreFromId((int)$id));
} catch (\Exception $e) {
echo json_encode(array('failure' => $e->getMessage()));
}
}
return $view_model;
}
And this is the method that retrieves the rows:
public function getStoreFromId(int $store_id) : array
{
if ($store_id != 0 || $store_id !== null) {
$query = $this->sql->getAdapter()->getDriver()->getConnection()->execute("SELECT COUNT(i.store_id) AS number_of_items,
stores.store_name, stores.store_description, stores.store_category, stores.store_image FROM items AS i
INNER JOIN stores ON stores.store_id = i.store_id WHERE stores.store_id = " . $store_id);
if ($query->count() > 0) {
$row = [];
foreach ($query as $value) {
$row[] = $value;
}
return $row;
} else {
$select = $this->select->columns(array('store_id', 'store_name', 'store_description', 'store_category', 'store_image'))
->from('stores')
->where(array('store_id' => $store_id));
$query = $this->sql->getAdapter()->query(
$this->sql->buildSqlString($select),
Adapter::QUERY_MODE_EXECUTE
);
if ($query->count() > 0) {
$row = [];
foreach ($query as $value) {
$row[] = $value;
}
return $row;
} else {
throw new \Exception("Could not locate store.");
}
}
} else {
throw new \Exception("Invalid store id given.");
}
}
When I call it, it is like this:
<img src="<?php echo $this->basePath() . $store['store_image']; ?>" alt="Your Store" style="width: 100%;" onclick="viewStore(<?php echo $store['store_id']; ?>);">
Now, that does show all the store ids but when I click on any id but the first image, I am getting this response (shown in screenshots)
https://imgur.com/a/4XFbKFI
I'm not sure why any of the ids that are not 23 do not load. Right now, all are listed from the stores table but only the id 23 actually works.
Any help would be appreciated.
Thanks!
The issue was with the query. I changed it to this:
SELECT stores.store_id,
(SELECT count(b.store_id) FROM items b WHERE b.store_id = " . $store_id . " and stores.store_id = b.store_id) AS number_of_items, stores.store_name, stores.store_description, stores.store_category, stores.store_image FROM stores
WHERE stores.store_id = " . $store_id
and it worked just fine.

How to implement logout in apollo-client

The authentication example found in the apollo docs is as follows:
https://github.com/apollostack/core-docs/blob/master/source/network.md#afterware
```
networkInterface.useAfter([{
applyAfterware({ response }, next) {
if (response.status === 401) {
logout();
}
next();
}
}]);
```
But what does the logout function look like? I'm unclear how to actually dispatch this as an action if it is indeed an action. The docs are really unclear on this and I haven't been able to find any example code anywhere. Any thoughts?
Look at my implementation:
const withUserHandlers = withHandlers({
logout: props => () => {
const { client, navigation, setUser } = props; // eslint-disable-line
removeTokenFromUse(client);
client.resetStore();
setUser(null);
const resetAction = NavigationActions.reset({
index: 0,
actions: [ NavigationActions.navigate({ routeName: 'Login' }) ],
});
navigation.dispatch(resetAction);
}
});

Angularjs query url parameter not set

Im my Angularjs-App the query url parameter datenbestand is not set: ?datenbestand=undefinded. Source code is as follows.
HTML
<select ng-model="datenbestand" id="datenbestand" name="datenbestand" class="span3 search-query">
<option value="A">A</option>
<option value="B">B</option>
</select>
CONTROLLER
app.controller( 'VListCtrl', [ '$scope', 'personlistdto', 'VListLoader', '$q', 'VService',
function( $scope, personlistdto, VListLoader, $q, VService ) {
$scope.personlistdto = personlistdto;
$scope.searchFactory = VListLoader;
$scope.search = function( ){
$scope.personlistdto = $scope.searchFactory();
};
}
] );
SERVICE:
services.factory( 'VService', [ '$resource',
function find( $resource ) {
return $resource( '/cdemo/rest/vers/ajs/:id',
{ id: '#id', datenbestand: '#datenbestand', isArray: false }
);
} ] );
services.factory( 'VListLoader', [ 'VService', '$q', '$route',
function( VService, $q, $route ) {
var find = function find() {
var delay = $q.defer();
VService.get( function( personlistdto ) {
delay.resolve( personlistdto );
}, function() {
delay.reject( 'Unable to fetch v' );
} );
return delay.promise;
};
return find;
} ] );
What am I doing wrong?
I'm new to Angular, but I'm wondering how you think your factory is getting access to datenbestand. I believe your problem is one of scope. When I do something similar to your code, it's not seeing it unless I specifically pass it, such as with a service, or making the call in the same scope.
I believe this post may help answer your question though. Hope that helps.

sfJQueryUIPlugin: No Picker for new records

Everyday is a new day with Symfony, but I'm loving it!
This morning I installed the sfJQueryUIPlugin. It has very little dependencies & accepts themeRoller styles. However, it has 2 issues:
[Feature_Request] There is no way to specify the year range. By default, it shows a 20 year range around the year in the field value. eg. if field value is 1993-01-20, the range will be 1983 to 2003.
??? Has anyone found a way out???
The DatePicker does not appear when the field is empty, Thus it does not show up during new record creation.
To solve this, I tried setting up the default value in the date input field (which now appears as a text input) using $this->setDefault('date_of_birth',date('Y-m-d'));
??? Is anybody facing this problem of picker now available during new record creation ???
??? Also is it the right way to set default value ???
Thanks in advance.
To get the date picker on the new registration form, I had to include javascripts in the indexSuccess template of my form (my fault)
as for the year range, I modified the plugin file to include additional parameter
class sfWidgetFormDateJQueryUI extends sfWidgetForm
{
protected function configure($options = array(), $attributes = array())
{
if(sfContext::hasInstance())
$this->addOption('culture', sfContext::getInstance()->getUser()->getCulture());
else
$this->addOption('culture', "en");
$this->addOption('change_month', false);
$this->addOption('change_year', false);
$this->addOption('number_of_months', 1);
$this->addOption('show_button_panel', false);
$this->addOption('theme', '/sfJQueryUIPlugin/css/ui-lightness/jquery-ui.css');
$this->addOption('year_range', '-30:+0');
parent::configure($options, $attributes);
}
public function render($name, $value = null, $attributes = array(), $errors = array())
{
$attributes = $this->getAttributes();
$input = new sfWidgetFormInput(array(), $attributes);
$html = $input->render($name, $value);
$id = $input->generateId($name);
$culture = $this->getOption('culture');
$cm = $this->getOption("change_month") ? "true" : "false";
$cy = $this->getOption("change_year") ? "true" : "false";
$nom = $this->getOption("number_of_months");
$sbp = $this->getOption("show_button_panel") ? "true" : "false";
$yrs = $this->getOption("year_range");
if ($culture!='en')
{
$html .= <<<EOHTML
<script type="text/javascript">
$(function() {
var params = $.datepicker.regional['$culture'];
params.changeMonth = $cm;
params.changeYear = $cy;
params.numberOfMonths = $nom;
params.showButtonPanel = $sbp;
params.yearRange = "$yrs";
$("#$id").datepicker(params);
});
</script>
EOHTML;
}
else
{
$html .= <<<EOHTML
<script type="text/javascript">
$(function() {
var params = {
changeMonth : $cm,
changeYear : $cy,
numberOfMonths : $nom,
showButtonPanel : $sbp,
yearRange : "$yrs"
};
$("#$id").datepicker(params);
});
</script>
EOHTML;
}
return $html;
}
public function getStylesheets()
{...
}
public function getJavaScripts()
{...
}
}
and setup the widget as:
$this->widgetSchema['date_of_birth']= new sfWidgetFormDateJQueryUI(array("change_month" => true, "change_year" => true, "theme" => "smoothness/jquery-ui-1.8.custom.css", "year_range" => "-30:+0"));

Resources